setting initial page number for loading for dhtmlxgrid compo

Hello,

I have problem loading custom page in dhtmlxgrid component.

Here is the scenario: user configures that she wants to see page 2 when she goes to a page with grid.

Is there a way, how to do this programmatically? (set initial page for loading)?

Moreover we need the requests to be done using POST and always (clear the cache of dhtmlxgrid)



We’ve found this way:



function onXleFunc(grid,count) {

    data = mygrid.getStateOfView();

    for (var i = data[1]; i<data[2]; i++) //for rows on current page

        mygrid.rowsBuffer[i]=null;

    return false;

}



mygrid.attachEvent(“onXLE”,onXleFunc);



gridQString = 'http://localhost:8080/xxx/data/data?’+searchUrlParams;

mygrid.loadXML(gridQString, function() { mygrid.changePage(somePage); });



This has several drawbacks:

1. there are always two downloads (always!)

2. the downloads of XML are made by “get”, not “post” HTTP methods, which we prefer

  1. there are always two downloads (always!)
    Yes, this is known side-effect of above scenario.
    Can be resolved as

    grid.attachEvent(“onDynXLS”,function(pos,start){
    if (pos==0 && somePage!=1) return false; // block second call
    return true;
    });
    mygrid.loadXML(gridQString, function() { mygrid.changePage(somePage); });

    >>2. the downloads of XML are made by “get”, not “post” HTTP methods, which we prefer
    You can use additional extension and postXML instead of loadXML
    dhtmlx.com/docs/products/kb/inde … t%20paging


Unfortunately this code doesn’t work. The problem is that with the first call to server (with no setting of posStart and count parameters), the onDynXLS event is never called!



Do you have any idea, how to hack the code to force htmlxgrid to not call the first call without the startPos and count paramters?

the onDynXLS event is never called!
This is expected , onDynXLS will be called only for automatic data loading calls, and not for the ones initiated directly.

With the same code as above, you can have

var gridQString = “grid.php?pos=”+somePage*pageSize+"&count="+pageSize;

In such case , first call will requiest and load data for required page, after which grid will generate second ( unwanted ) data call , which will trigger onDynXLS event, and will be blocked.