Categories | Question details Back To List | ||
Problem with calculating number of pages in dhtmlxgrid In dhtmlxgrid Professional I use the following setup, based on the large grid php/mysql example, but with paging added: mygrid.setXMLAutoLoading("loadGrid.php?un="+Date.parse(new Date()),15); mygrid.enablePagingWT(true,15,1,"pagingArea"); mygrid.loadXML("loadGrid.php?un="+Date.parse(new Date())); showLoading(); var header_var=mygrid.attachHeader("#rspan,<input onclick='stop_Propagation(event)'; type='text' id='search_nm' onkeydown='doSearch(arguments[0]||event)'>,<input type='text' id='search_cd' onclick='stop_Propagation(event)'; onkeydown='doSearch(arguments[0]||event)'>,#rspan,#rspan,#rspan,#rspan,#rspan,#rspan,#rspan"); My loadgrid.php is also based on the large grid php/mysql example, but uses a table of about 1100 records. As far as I can see in this example, a $count variable is set to 100 by default (when no other value is posted by client). And indeed, the grid shows a count of 100 records on initial loading. No problem with this, since it's meant to be like that. In general this setup performs quite well. However, there seems to be a problem with the calculation of available pages, and only on initial loading: with the default length of 15 records per page, the toolbar page select box shows options for 69 pages where there should only be 7 for 100 records. Everything goes well as long as the user chooses one of the first six pages. When the seventh page (or higher page, or last page button) is selected, it is shown correctly for about 2 seconds, then the grid jumps by itself to the first page, and shows this first page without the additionaly attached headers missing . When I comment out the autoloading line, a "too much recursion" javascript error is thrown when selecting a page higher than six. When choosing another page size, the problem stays the same: all pages shown correctly, but the last page (when it has less records than allowed by pagesize) behaves strangely. Also the user is allowed to select pages beyond the last existing one (which results in empty pages and errors of course). This problem occurs only after an initial loading of the page. If after initial loading a search is performed immediately (using the search_nm or search_cd inputs), everything works fine from then on, including the right number of pages, and no more errors. This continuous to work well, even when calling all records again with a blank search. There seems to be a relationship between these problems and the default setting of $count to 100, since the problem is solved once this default setting is overruled for one time by the client. But I was not able to see how I could solve it permanently. Is there a way to show the last page correctly on initial loading, and to prevent the user picking a page beyond the last one? Best regard, Marc. Answer posted by marc on Jul 20, 2007 12:08 Correction to my previous post: using search fields does not (always) correct the problem....I will go on looking for more clues on this problem... best regards, Marc Answer posted by Darya (Support) on Nov 28, 2014 19:56 I hope this information will be enough for you. But you also can have a look at dhtml context menu and php user interface. |