| Page 1 of 2 | [ 19 posts ] | Go to page 1, 2 Next |
|
Hi,
I was implementing pagination and used client-side first and everything was fine, I obtained my DataSource, defined Paginator in configuration and displayed the table. then the requirements changed and I had to implement server-side pagination. I defined configuration like that : Code: var myConfig = { dynamicData: true, height:"400px", initialRequest: "sort=account&dir=asc&startIndex=0&results=500", paginator: new YAHOO.widget.Paginator({ rowsPerPage:25 }), sortedBy : { key:'account', dir: YAHOO.widget.DataTable.CLASS_ASC} }; Data Source : Code: "recordsReturned": 100, { [ ..... ], "totalRecords": 500, "startIndex": 0, "dir": "asc", "pageSize": 10 } My DataSource contains "totalRecords" and all other necessary meta data. and at that point pages links disappeared. |
|
If your data is not enclosed in curly braces, that is an error, but I guess it is just a copying error.
This might help: http://www.yuiblog.com/blog/2010/09/02/ ... lean-code/ |
|
Satyam,
thank you for answering. I don't think it's a problem with the JSON because the DataTable is generated correctly - I have 100 records on the screen. The problem is that totalRecords number is 500 and I suppose to have 5 links on the page and I don't. Somehow the system doesn't recognize that there are more records available than initially loaded. |
|
VS_0511,
did you define your own handleDataReturnPayload() in your datatable to pass the pagination data generated by the server to your object? did you define your paging fields in the meta section of your datasource? |
|
1.
myDataTable.handleDataReturnPayload = function(oRequest, oResponse, oPayload) { oPayload.totalRecords = oResponse.meta.totalRecords; return oPayload; }; - yes, I defined it. ******************** My paging fields in the meta section of the DataSource : "recordsReturned": 100, "totalRecords": 500, "startIndex": 0, "dir": "asc", "pageSize": 5 ------------------------------------ My DataSource is valid, I tested it in JSONlint. |
|
I had similar issues with my table. One of the pieces I put in place was this extended handler
Code: handleDataReturnPayload: function(request, response, data) { // needed for pagination var rm = response.meta; data.totalRecords = rm.totalRecords; data.pagination.recordOffset = rm.startIndex; data.pagination.rowsPerPage = rm.pageSize; // handles the UI state to show the sorting var DT = YAHOO.widget.DataTable; data.sortedBy.dir = (rm.dir == 'desc' ? DT.CLASS_DESC : DT.CLASS_ASC); data.sortedBy.key = rm.sort; return data; } |
|
Also I should note that my JSON response looks like the following with 'records' being my array of data objects
Code: { dir: 'asc', pageSize: '10', recordsReturned: '10', sort: 'someId', startIndex: '1', totalRecords: '42', records: [{/*record here*/}] } |
|
Thank you : my JSON looks like :
{ records:[ { record1}, {record2} ... ], "recordsReturned": 100, "totalRecords": 500, "startIndex": 0, "dir": "asc", "pageSize": 5 } I am wondering when "handleDataReturnPayload" is called. I tried to put an alert there but it never popped up. Also, in my JSON document I have 3 sections : columnDef ( I called it meta ), responseSchema and records. In ResponseSchema section I have "metaFields" attribute defined with <key,value> : "totalRecords":"totalRecords". In "records" section I have pagination attributes defined after the actual records. Still doesn't work. Is there any way to debug it? |
|
Can you show your datasource config? If you don't have your metaFields defined correctly in the responseSchema section they won't be made available inside the handleDataReturnPayload callback.
Posting the whole javascript code, wrapped in code tags would help. |
|
In place of the pages links I have that :
<< first< prevnext >last >> - nothing is clickable. It seems like the Payload object doesn't have pagination attributes initialized. |
| Page 1 of 2 | [ 19 posts ] | Go to page 1, 2 Next |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group