Saturday, December 18, 2010

DHTMLXGrid subgrid paging

To create paging in subgrid, one must create a row in the table.
The example below put up paging as footer.
The enablePaging should only be call when loading data.
This is because the grid is not created yet, therefore the div did not exists yet.


mygrid.attachEvent("onSubGridCreated",function(subgrid, id){
//collapse all other subgrid
subgrid.setHeader("#master_checkbox,Id,Name,Age");
subgrid.setColTypes("ch,ro,ro,ro");
subgrid.setInitWidths("40,50,100,100");
subgrid.init();
subgrid.enableAutoHeight(true);
//notice the div is given the unique id
//the trailing #cspan to set colspan of the other column to merge with 1st column
// therefore, the #cspan have to match your column count-1
subgrid.attachFooter("<div id="subgrid_h" + id + "" style="width:100%;"></div><div id="subgrid_f" + siteid + "" style="width:100%; height: 20px;"></div>,#cspan,#cspan,#cspan");

subgrid.load("http://example.com/path_tojson?count=10&posStart=0&siteid=" + siteid,function() {
subgrid.enablePaging(true, 10, 10, "subgrid_h" + siteid, true, "subgrid_f" + siteid);
subgrid.setPagingSkin("bricks");
subgrid.setSizes();
subgrid.callEvent("onGridReconstructed", []);
}, "json");

return false; // block default behavior
});

2 comments:

AMIT LONKAR said...

thx was very helpful. What is this siteid variable that you are using ?

JAVA Helping Hands said...

hai in my program i loaded data from xml file using load() and performing paging .
i have 8 rows and i want to see two rows for each page it is showing page 1 and page 2 by using changePage(),

but after page 2 it is stucking there it even not showing an alert message also.

i am using setTimeout() to go to page 2.... from there to page 3 but it stuk there itself....

i have also tried onpagechange event also but not familiar with so facing some problems


is there any other way to perform paging automatically using events......


please help.............
thanks with regards.........