[DT 1.9.4] Pagination not working when "bSort" set to true.
[DT 1.9.4] Pagination not working when "bSort" set to true.
Hi, I am using datatable 1.9.4 and ajax data source (a backbone collection) to populate the table. Here is how I initialize the datatable.
this.dataTable = this.$tableEl.dataTable({
"sDom": '<"dataTables_inner spacing-base" t><"bottom"ip>',
"bFilter":false,
"bLengthChange":false,
"bPaginte":true,
"sPaginationType" : "full_numbers",
//"bSort":false,
"bStateSave":true,
"aoColumnDefs": [{
"aTargets" : [0],
"mData": "a",
"bSortable": false,
"mRender": function(data, type, full){
return data;
}
},
{
"aTargets" : [1],
"mData": "b",
"bSortable": false,
"mRender": function(data, type, full){
return data;
}
},
{
"aTargets" : [2],
"mData":"c",
"bSortable": false,
"mRender": function(data, type, full){
return data;
}
},
{
"aTargets" : [3],
"mData": "d",
"bSortable": false,
"mRender": function(data, type, full){
return data;
}
},
{
"aTargets" : [4],
"mData": "e",
"bSortable": false,
"mRender": function(data, type, full){
return data;
}
}
],
"sAjaxSource": "",
"sAjaxDataProp": "",
"fnServerData" : function(sSource, aoData, fnCallback){
fnCallback(collection.toJSON());
}
});
And whenever I have new data on the collection, I call this.dataTable.fnReloadAjax();
However, the pagination is not working using the above code, it works only when i UNCOMMENT the //"bSort":false on line 7.
But I cannot use that as I need to sort the table based on the first column (will have "bSortable":true for first column.
Any ideas what am I missing? Thanks a lot.
Answers
Per the forum rules, please link to a test case showing the issue.
Allan
I was using fnReloadAjax() to reload the data. Issue was solved by changing the call to fnReloadAjax(null, null, true).
Thanks Allan.