View Full Version : Paging Grid issue: shows all data in the first page
Greeens
22 Feb 2007, 4:53 PM
Hi all,
I tried to follow the example on the blog, loading xml file, doing the paging and put the datamodel in a gridpanel, but I don't know why I got the result with the paging toolbar at the bottom, but with all records loaded on the first page, ie. there is no paging implemented. Here is my code:
sm = new YAHOO.ext.grid.SingleSelectionModel();
dataModel.addListener('load', sm.selectFirstRow, sm, true);
dataModel.initPaging('../report/info.xml',10);
// create the Grid
var grid = new YAHOO.ext.grid.Grid('pick_status', dataModel, colModel,sm);
//grid.autoWidth = true;
//grid.autoHeight = true;
grid.render();
dataModel.loadPage(1);
The I would load the whole datamodel into a grid panel.
Would anyone know please help!!!
Thanks
tryanDLS
22 Feb 2007, 5:14 PM
The paging functionality does not page an xml document. You need to feed the correct page from that xml file from your server functionality. Each time you click Next, your server method returns the request page based on the pageNum and pageSize passed in.
Greeens
22 Feb 2007, 6:09 PM
Hm.. Sorry I don't quite get what you mean..
Are you saying that the xml paging functionality does not sperate the pages for me automatically?
I have to use my php file to manually do the paging by myself?
Then how about sorting?
If I'm doing manual paging, the sort column functionality would become meaninless?
Greeens
23 Feb 2007, 8:55 AM
Would anyone please help?!!
Thanks!
Animal
23 Feb 2007, 9:03 AM
Yes, it is genuine remote paging. The grid sends a request with parameters asking for a certain page of a certain size, and your server-side component must supply that, not the whole dataset... otherwise it's not actually "paged" is it?
Look at the parameter map in your PHP script. You should see (IIRC) "page" and "pageSize".
Greeens
23 Feb 2007, 10:28 AM
Thanks for your reply Animal.
How about sorting?
If i'm passing parameters to my server page to only get part of the the data, when I do a sorting on certain column, does my server side page has to handle that as well?
tryanDLS
23 Feb 2007, 11:40 AM
That depends on what sorting means to you for the specific case. Let's say you have 50 names, 10 names to a page, in default order by ID. You retrieve page 1 of the data and the user wants to sort by name.
1) If you just want to sort the currently retrieved page by name that can be done on the client, specific to the current page of data on the client.
2) If on the other hand, sorting by names implies that you see the first page of ALL data, sorted by name, you have to handle that on the server. The page request has to include the sortorder parm and you now have to pass that to your DB engine as part of an ORDERBY clause.
Greeens
27 Feb 2007, 7:55 AM
I'm not sure if I understand this.
Let say I've an XML file, each records have 3 fields: Order-ID, Product, Quantity. I have 100 records in total and I want to display 10 records a page.
Initially, I've to use my own php server script to only provide the first 10 records to display. When the user click next page, it will call my php sever script to generate the next set of 10 records data.
When the user click the column header to sort, then I have to call my php on the server again to do the ordering in the server side and return a 10 records data set to the page manually? Where do I call the php script when the user click the column header to sort?
I'm quite confused. Would anyone please help???
Thanks soooo much..
BernardChhun
27 Feb 2007, 8:29 AM
I'm not sure if I understand this.
Let say I've an XML file, each records have 3 fields: Order-ID, Product, Quantity. I have 100 records in total and I want to display 10 records a page.
Initially, I've to use my own php server script to only provide the first 10 records to display. When the user click next page, it will call my php sever script to generate the next set of 10 records data.
When the user click the column header to sort, then I have to call my php on the server again to do the ordering in the server side and return a 10 records data set to the page manually? Where do I call the php script when the user click the column header to sort?
I'm quite confused. Would anyone please help???
Thanks soooo much..
you don't have to make the call yourself for the remote ordering. It is done automatically. The url you use to fetch your data is saved as a property of the grid. The post values will all be the same except that for these 2:
* sortColums = the index of the column
* sortDir = ASC or DESC
you just have to catch these two in your php and make the corresponding select sentence.
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.