jQWidgets Forums

jQuery UI Widgets Forums Grid Cancel a grid datasource change

This topic contains 3 replies, has 2 voices, and was last updated by  Dimitar 10 years ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Cancel a grid datasource change #70156

    Satch
    Participant

    Hi,
    In a function I am changing the data in a grid by changing the data adapter’s url and then setting the grid’s source to that new data adapter.
    I am calling this function and passing an “id” parameter when users select row values in another grid.

    function getNotes(idkey) {
    
         var   mySource = {
                datatype: "json",
                url: 'data.aspx?id=' + id,
                datafields: [
                                { name: 'id', type: 'number' },
                                { name: 'noteDate', type: 'string' },
                                { name: 'noteContent', type: 'string' }
                            ]
              };
    
        var myAdapter = new $.jqx.dataAdapter(mySource);
    
        $("#myNotes").jqxGrid({ source: myAdapter });
    
    }

    The problem I am having is that when the user clicks rapidly, the grid binding must be completed first (or an error will be thrown). I don’t want to use the “bindingcomplete” callback for the binding to complete, I just want that process to abort.

    Is there a method to cancel the current process of a grid binding so I don’t have to wait until the last process to finish binding. Since the user is choosing a new row, they don’t need to see the grid populate with the last values.

    Thanks,
    Satch

    Cancel a grid datasource change #70164

    Dimitar
    Participant

    Hi Satch,

    You cannot stop a binding operation that is currently being processed. You can, however, prevent new bindings from being initiated before the first one is complete. If this option suits your needs, we can guide you how to achieve it.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Cancel a grid datasource change #70451

    Satch
    Participant

    Thanks for the response Dimitar,

    Currently, I’m trying to prevent new bindings from being initiated by disabling the grid used for selecting and then enabling it on ‘bindingcomplete’ function. Is there a better way to achieve that?

     $("#myNotes").on('bindingcomplete', function () {
                $("#userList").jqxGrid({ disabled: false });
                }
            });
    
    Cancel a grid datasource change #70471

    Dimitar
    Participant

    Hi Satch,

    You can achieve this through the use of a flag variable, e.g.:

    var binding = false;
    
    ...
    
    // you call getNotes here
    if(binding === false) {
        getNotes(idkey);
    }
    
    ...
    
    function getNotes(idkey) {
        binding = true;
    
        var mySource = {
            datatype: "json",
            url: 'data.aspx?id=' + id,
            datafields: [{
                name: 'id',
                type: 'number'
            }, {
                name: 'noteDate',
                type: 'string'
            }, {
                name: 'noteContent',
                type: 'string'
            }]
        };
    
        var myAdapter = new $.jqx.dataAdapter(mySource);
    
        $("#myNotes").jqxGrid({
            source: myAdapter
        });
    
    }
    
    ...
    
    $("#myNotes").on('bindingcomplete', function() {
        binding = false;
    });

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.