Set current active page while initializing a grid

Hi,

I would like to be able to set the current active page while initializing my grid.

Especially, i’d like the current active page to be anything but the first page.

I’ve got these different steps for my init:

mygrid.setHeader(…);
mygrid.attachHeader(…);
mygrid.setColAlign(…);
mygrid.enableTooltips(…);
mygrid.setColSorting(…);
mygrid.enableAutoHeight(…);
mygrid.enableAutoWidth(…);
mygrid.setInitWidthsP(…);
mygrid.setColTypes(…);
mygrid.attachEvent("…",function(subgrid,id,ind,data){
…;
});
mygrid.init();
mygrid.enablePaging(…);
mygrid.setSkin(…);
mygrid.setPagingSkin(…);

For now, i’m just doing a changePage(selectedPage) after the ‘mygrid.init()’ operation, but it doesn’t work.

However, this does work:

mygrid.init()
alert(“some text”);
mygrid. changePage(selectedPage);

Obviously i’d like to not use the alert box.

Thanks in advance for your help

You may change the page only when the data is loaded to the grid.
Please, try to use onXLE event or a callback of load method:

mygrid.load(url,function(){ mygrid. changePage(selectedPage); })

Thank you very much, i used the XLE event and it works.

Now i’m facing another problem which is a bit tricky to explain (occuring only on I.E, i’m using I.E 7).

I’m using AJAX to save the current page of my grid in a cookie (i’m using J2E, so my server side processes are coded in JAVA (actions)):

mygrid.attachEvent(“onPageChanged”, function(ind,fInd,lInd){
var actionUrl = “/web/saveCookieForPaginationValue.do?pageName=”+pageName+"&currentPage="+ind;
var xhr = getXMLHttpRequest(); //this function

		xhr.open("GET", actionUrl, true);
		xhr.send(null);

});

When i change my page in the grid for the first time, i go through the Java Action Class: the AJAX process is working and i go through my server side process.

However, when i go back into a page where i have already been, i go through the event but i don’t go through the AJAX process, so i can’t change the current page number.

I don’t have this problem with Firefox.

Do you have any tips? I hope i have been clear enough.

Thanks in advance.

correction: “However, when i go back into a page where i have already been, i go through the event but i don’t go through the AJAX process, so i can’t SAVE the current page number.”

Ok i found and corrected my problem, which was not linked to DHTMLX.

The problem came from the AJAX request.

I used instead the AJAX request given by the ‘Protoptype Javascript API’, giving me:

mygrid.attachEvent(“onPageChanged”, function(ind,fInd,lInd){
var actionUrl = “/web/saveCookieForPaginationValue.do?pageName=” + pageName + “&currentPage=”+ind;
//var param = “pageName=” + pageName + “&currentPage=”+ind;
var myAjax = new Ajax.Request(
actionUrl,{
onSuccess: function(response) {
}
});
});

And this works perfectly.