Pagination resets after table.reload()
Pagination resets after table.reload()
Im working on datatables version 1.9.4.
I have a problem with my pagination. I have some functionallity that allows you to add a comment to a row, and the tables will reload with the new data. The problem is that when the reload finish the pagination resets to first page.
I have literally tried everything and have read allmost all discussions in here about that and googled a lot. Can anyone please help??
My code:
THE VIEW:
MyTable= initMyTable();
confMyTable();
.....
function initMyTable() {
return $('#myTable').dataTable(defaultDataTable({
oSelectedRow: null, //used for multiselect
oDeSelectedRow: null, //used for multiselect
oIncidentList: null, //used for multiselect
bFnRowSelectedLeave: false, //used for multiselect
sDom: '<"header"FCMT><"data-table"<"subtitle">Rrt>',
bPaginate: true,
sCookiePrefix: 'YBAIncidents',
bStateSave : true,
fnDrawCallback: function( oSettings ) {
//I only use this to set the correct value in the UI pagination
var pageText = updatePageNumber("#myTable", this);
//I only use this for testing the pagination is returning the correct value
var settings = this.fnPagingInfo().iStart;
console.log(settings)
},
aoColumns: [ .... ]
MY RELOAD FUNCTION:
function confMyTable() {
moduleTables['#myTable'] = MyTable;
MyTable.reload = function () {
if (!this.aoMetaData)
return;
if (postponeReload(this))
return;
//Datetime used from another table, to get the data from this date
var dateTimeFilter = DateTimeFilter.fnGetData(sitesTable);
this.aoAjaxData = { anotherSideID: this.aoMetaData.anotherSideID, StartTime: convertDMYtoYMD(dateTimeFilter.from), EndTime: convertDMYtoYMD(dateTimeFilter.to) };
this.fnReloadAjax('/MyController/MyActionResult', function () {
});
};
Answers
Anyone??
Sorry - 1.9.4 is legacy and no longer supported. The
ajax.reload()
method in 1.10+ has a standing redraw option.Having said that,
fnReloadAjax
does also have a similar option - see its plug-in page (third parameter you pass into it should betrue
I think).Allan