How to redraw data table, by putting IdisplayStart runtim.

How to redraw data table, by putting IdisplayStart runtim.

BASUDEBBANERJEEBASUDEBBANERJEE Posts: 13Questions: 4Answers: 0

Hi guys, I am trying to set up IdisplayStart dynamically and with below mentioned code it is working fine only data serial changes , it is stayed on current page but current page first data at the time of loading, become current page last data after reloading.
Just go through the code and let me know for any changes. By the way iDisplayLength working fine. please check the data table setting also for any required changes.
Thanks in advance.

var oSettings = tbl.fnSettings();
                    oSettings.iInitDisplayStart = p;
                    tbl.fnDraw();
                    
//here p is the page number.

                    //var oSettings = tbl.fnSettings();
                    //oSettings._iDisplayLength = 10;
                    //tbl.fnDraw();
                    }
                else {
                    table = table.dataTable({
                        paging: true,
                        "iDisplayLength": 5,
                        //"aLengthMenu": [[5, 10, 15, 25, -1], [5, 10, 15, 25, "All"]],
                        "bFilter": false,
                        "bInfo": false,
                        "bLengthChange": false,
                        "bSort": false,
                        //"bStateSave":true,
                        "order": [[0, "asc"]],
                        
                        columnDefs: [
        { orderable: false, "targets": 3 }
                      ]
                    });
                }
            }        

Answers

  • BASUDEBBANERJEEBASUDEBBANERJEE Posts: 13Questions: 4Answers: 0

    At last I solved the problem by holding the current page info and set that one as current page , by the below mentioned code.

    var p = tbl.fnPagingInfo().iPage;
                        tbl.fnClearTable();
                        for (var i = 0; i < rows.length; i++) {
                            tbl.fnAddData($(rows[i]));
                        }
                        tbl.fnPageChange(p); 
                        }
    
This discussion has been closed.