iDeferLoading & paging
iDeferLoading & paging
mcbutterbuns
Posts: 7Questions: 0Answers: 0
Hello,
I've enabled iDeferLoading (what a wonderful new feature) on my table. However, I'm also employing pipelining to load 150 records spanned over 3 pages (page size of 50).
When I render the table, I print out my 150 records and have iDeferLoading turned on. Instead of taking the 150 records and pushing them into 3 pages, the first page is 150 records long.
Is there anyway to have datatables respect the page size with an initial dataset larger than the initial page?
I've enabled iDeferLoading (what a wonderful new feature) on my table. However, I'm also employing pipelining to load 150 records spanned over 3 pages (page size of 50).
When I render the table, I print out my 150 records and have iDeferLoading turned on. Instead of taking the 150 records and pushing them into 3 pages, the first page is 150 records long.
Is there anyway to have datatables respect the page size with an initial dataset larger than the initial page?
This discussion has been closed.
Replies
Allan
If there's not a solution at this time, I can easily work around it but just curious if there was anything I may be missing.
[code]
$('#table').dataTable({
"bJQueryUI": true,
"aoColumns": [
{
"bSearchable": false,
"bSortable": false,
"bVisible": true,
"sType": "html"
}
],
"aaSorting": [
[
3,
"desc"
]
],
"iDeferLoading": 2905,
"bSort": true,
"bPaginate": true,
"sPaginationType": "full_numbers",
"bInfo": true,
"bFilter": false,
"bAutoWidth": false,
"iDisplayLength": 50,
"bLengthChange": true,
"aLengthMenu": [
25,
50,
100,
250
],
"bStateSave": false,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/path/to/data",
"oLanguage": {
},
"fnRowCallback": rowCallback,
"fnServerData": function(sSource,aoData,fnCallback){
fnDataTablesPipeline(sSource, aoData, fnCallback, 3);
},
asSorting: [
]
});
[/code]
[quote]When I render the table, I print out my 150 records and have iDeferLoading turned on. Instead of taking the 150 records and pushing them into 3 pages, the first page is 150 records long.[/quote]
What iDeferLoading makes DataTables do is basically leave whatever you have in the table alone when DataTables would normally do its first draw. So you've got 150 records and DataTables just leaves them as they are - it won't try to do a proper "draw" with them, which would be required for the paging to work as expected.
So there are two options which spring to mind:
1. Simply display only the first page of 50 in the HTML (which was what I had been expecting the use of this feature would entail)
2. Use Javascript to remove rows 51+ just before you initialise your DataTable. This way it will keep 150 rows for non-JS users, and paging will work as expected for JS users.
Allan
Thanks for your help. I think I'll just show the initial 50 records and let subsequent paging do the rest of the dirty work.
Since the table will show the most recent data, user's wont be paging beyond the first page for most of the time so this will still reduce the number of round trips.
Thanks again!