Call back state stave position of table after load more records

Call back state stave position of table after load more records

pnguyen2609pnguyen2609 Posts: 1Questions: 1Answers: 0

Hi All
I'm a newbie and I have a requirement to apply new changes on datatable.
1/ If user is on 1st pagination button then click Next, it will be navigated to second pagination button.
2/ Until the last pagination button (10th pagination button), user click next then it will be call function loading more records from database and refresh page.

DataTable.ext.renderer.pageButton.bootstrap = function ( settings, host, idx, buttons, page, pages ) {
var api = new DataTable.Api( settings );
var classes = settings.oClasses;
var lang = settings.oLanguage.oPaginate;
var aria = settings.oLanguage.oAria.paginate || {};
var btnDisplay, btnClass, counter=0;

var attach = function( container, buttons ) {
    var i, ien, node, button;
    var clickHandler = function ( e ) {
        e.preventDefault();
        if ( api.page() != pages-1 || e.data.action != "next" ) {
            api.page( e.data.action ).draw( 'page' );
        }else{ // if in the last position, user click next, table will be loaded more records by PFKey90
            doAction('PFKey90');
            api.page(pages+1).draw( false );
            settings.oFeatures.bStateSave = settings.oInit.bStateSave = true;
        }
        settings.oApi._fnLoadState( settings, settings.oInit );
    };

    for ( i=0, ien=buttons.length ; i<ien ; i++ ) {

button = buttons[i];

$(document).ready(function() {
var table = $('#dataTables').DataTable({
ordering: false,
searching:false,
scrollX: true,
scrollCollapse:true,
scrollY: "580px",
autoWidth: false,
columnDefs: [
{ width:'85px', targets:0},
{ width:'40px', targets:[4,6]},
{ width:'50px', targets:5},
],
stateSave: true,
"fnInfoCallback": function( settings, iStart, iEnd, iMax, iTotal, sPre ) {
var iTotal = $('#totalRecords').val();
return "Showing " + iStart + " to "+ iEnd + " of " + iTotal + " entries";
},
});
3/ Then page will be refreshed and it will be on 11th pagination button.

Can you guy please help to guide me how I can call back the 11th position after page is refreshed and table was draw?

This discussion has been closed.