fnDraw doesn't seem to be updating pagination controls
fnDraw doesn't seem to be updating pagination controls
jonwah
Posts: 4Questions: 0Answers: 0
Hi guys,
I'm using DataTables to get dynamic data from a .NET MVC App, and return the data to the client.
Everything is hooked up and working fine - and I had pagination disabled to start off with, but as our data sets have grown it has become needed to enable it for the UI.
Problem is, my table is controlled via a drop down. It may well have no or very few rows to start off with, but when calling fnDraw on the drop down change, it may return heaps more rows. When this happens, the PREV and NEXT buttons don't become enabled (still styled as disabled, click doesn't do anything). I've tried both pagination types - the only discernible change is that when "full_numbers" is turned on, on load (with a table with no rows), it says "first prev next last", changing to data with 300 rows (20 shown), gives first prev 1 next last.
Firebug reports the response as iTotalRecords = 318, iTotalDisplayRecords = 20.
Heres my initialization javascript:
[code] $('#allHazardsDataTable').dataTable({
"bPaginate": true,
"bLengthChange": false,
"iDisplayLength": 20,
"iDeferLoading": 100,
"iDisplayStart": 0,
"asStripeClasses": ['row', 'altRow'],
"bFilter": false,
"bSort": false,
"bInfo": false,
"bAutoWidth": true,
"bServerSide": true,
"sPaginationType": "full_numbers",
"sAjaxSource": "/LiveData/AllHazards",
"bProcessing": false,
"fnServerParams": function (aoData) {
aoData.push({ "name": "StageId", "value": $('#hazardsStageSelect').val() },
{ "name": "EventId", "value": window.EventId });
},
"aoColumns": [
{ "sName": "CarNumber" },
{ "sName": "Status" },
{ "sName": "StageNumber" },
{ "sName": "Distance" },
{ "sName": "Latitude" },
{ "sName": "Longitude" },
{ "sName": "Time" }
]
});[/code]
Any ideas? Scratching my head here...
I'm using DataTables to get dynamic data from a .NET MVC App, and return the data to the client.
Everything is hooked up and working fine - and I had pagination disabled to start off with, but as our data sets have grown it has become needed to enable it for the UI.
Problem is, my table is controlled via a drop down. It may well have no or very few rows to start off with, but when calling fnDraw on the drop down change, it may return heaps more rows. When this happens, the PREV and NEXT buttons don't become enabled (still styled as disabled, click doesn't do anything). I've tried both pagination types - the only discernible change is that when "full_numbers" is turned on, on load (with a table with no rows), it says "first prev next last", changing to data with 300 rows (20 shown), gives first prev 1 next last.
Firebug reports the response as iTotalRecords = 318, iTotalDisplayRecords = 20.
Heres my initialization javascript:
[code] $('#allHazardsDataTable').dataTable({
"bPaginate": true,
"bLengthChange": false,
"iDisplayLength": 20,
"iDeferLoading": 100,
"iDisplayStart": 0,
"asStripeClasses": ['row', 'altRow'],
"bFilter": false,
"bSort": false,
"bInfo": false,
"bAutoWidth": true,
"bServerSide": true,
"sPaginationType": "full_numbers",
"sAjaxSource": "/LiveData/AllHazards",
"bProcessing": false,
"fnServerParams": function (aoData) {
aoData.push({ "name": "StageId", "value": $('#hazardsStageSelect').val() },
{ "name": "EventId", "value": window.EventId });
},
"aoColumns": [
{ "sName": "CarNumber" },
{ "sName": "Status" },
{ "sName": "StageNumber" },
{ "sName": "Distance" },
{ "sName": "Latitude" },
{ "sName": "Longitude" },
{ "sName": "Time" }
]
});[/code]
Any ideas? Scratching my head here...
This discussion has been closed.
Replies
These two values should only be different if you have a filter applied to the table: http://datatables.net/usage/server-side .
iTotalDisplayRecords is the number of records, after filtering, but regardless of paging. If DataTables needed to get the length of the data returned it would just do aaData.length :-).
Allan
http://www.codeproject.com/Articles/155422/jQuery-DataTables-and-ASP-NET-MVC-Integration-Part#Pagination
Where it seemed to indicate that the paged selection count should be returned as the iTotalDIsplayRecords - thanks for your help, it's working great now!