Dhtmxgrid with pagination issues

Hi All,

I am loading 1000 records from database using pagination, i.e. 100 records per page across 10 pages. The first page is loaded with 100 records and the information is shown to user, i.e. “Records 1 from 100 of 1000” appears with page numbers (I am using bricks paging skin) such that the user will know how many records are there in total. Thereafter, when another page is clicked another set of 100 records are loaded from the db.

Issues which I am facing :-

  1. When user selects to go on another page, using split mode the data on left side of grid does not change, i.e. it remains the same as it was loaded on the first page, however the right hand side data does change though. Removing the split mode everything works fine.

Please can anyone help on how to change the grid data on left hand side using split mode with pagination.

  1. Another issue which comes up is with grid’s “onEditCell” event. As the user is notified of total number of records, i.e. 1000, by assigning this value to total_count attribute of rows tag in xml, so now when I ONLY want to get the total number of records which are displayed on the page I use the following code:-

var totalRowsOnPage = mygrid.getRowsNum();
alert(totalRowsOnPage);

But “totalRowsOnPage” gives me 1000 instead of 100. How can I get the total no of rows which are being shown to the user?

Thanks in advance for your help.

-Sam

  1. Be sure that you have enablePaging command before splitAt. If issue still occurs - please provide any kind of sample or demo link where it can be checked.

var state = grid.getStateOfView(); //state = [page, start_row, end_row]; alert(state[2]-[state[1]);

Thanks Stanislav for replying on it.

"1) Be sure that you have enablePaging command before splitAt. If issue still occurs - please provide any kind of sample or demo link where it can be checked. "

  • It did not work. Please let me know how to create a demo link.

The code which you have provided does work for giving total number of rows which are shown on the page.

I have another issue, which I forgot to mention, which is --> When I switch between pages, the pages are loaded from db and stored in cache, such that when I come back to that page it is taken from the cache not from db.

Is there any way with which I can retrieve the records from db every time when user changes the page.

Thanks in advance.

-Sam

Update --> The grid split mode issue is fixed. After going through dhtmlxgrid.js I found the below code under setSkin function :-

this.setSkin=function(name){
....
.....
if (_isIE)
		this.preventIECaching(true);
}

Which was making the browser, i.e. IE in my case, caching the records. Putting the below line of code before grid initialization:-

mygrid.preventIECaching(false);
mygrid.init();

in my loadGrid function fixed the issue for displaying updated/new data in split mode correctly.

However, I am still working on to figure out a way with which I can retrieve the records from db every time when user changes the page.

Please let me know if anyone has an idea or have implemented similar functionality before.

Thanks for your help.

-Sam

When I switch between pages, the pages are loaded from db and stored in cache, such that when I come back to that page it is taken from the cache not from db.
Is there any way with which I can retrieve the records from db every time when user changes the page.

Please, try to use the following custom function:

mygrid.attachEvent("onBeforePageChanged", function(ind,count){ firstRow=mygrid.getStateOfView()[1];//get the index of the first row on the leaving page lastRow=mygrid.getStateOfView()[2];//get the index of the last row on the leaving page for (i=firstRow;i<=lastRow;i++){ mygrid.rowsBuffer[i]=0; //clear the cache of the row from the leaving page } return true; });

Thanks a lot sematik. Your solution worked like a charm for my requirement and saved me a lot of time.

I really appreciate it.

For the answer which I have posted earlier regarding IE caching as below, made the grid to display the data correctly first time, and thereafter when i remove the line “mygrid.preventIECaching(false);” everything was working fine. I am not sure why the grid was not displaying the correct data before.

"Which was making the browser, i.e. IE in my case, caching the records. Putting the below line of code before grid initialization:-

mygrid.preventIECaching(false);
mygrid.init();

So adding the above line of code was not a workaround, may be something else was causing the issue.

Thanks DHTMLX support for providing solutions on my issues.

-Sam

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…

Unfortunately your issue cannot be reproduced locally.
Please, make sure that each row in your data has a unique id.

If the problem still occurs for you, please, provide with any kind of a sample of your code or with a complete demo, where the issue can be reconstructed.