weixin_33682719 2016-01-11 04:41
浏览 28

数据表分页指向

I am developing a web application that having a datatable plugin.

I am fetching table rows as Datatable Dynamically with ajax.

Each row contains an edit button and delete button.

For Ex: when I switch to page 3 and click the edit button its gone to the edit page.

After submitting the page system will force to redirect to table list page.

On that time datatable showing from the first page in datatble. I want to show the 3 rd page.

How can I change this from page 3 ?

 var oTable = $('.dataTable').DataTable( {
      "processing": true,
      "serverSide": true,
      "bLengthChange": false,
      'iDisplayLength':5,
      "bSort": false,// disable sort options
      "aoColumnDefs": [{ "bSortable": false, "aTargets": [ "_all" ],"sClass": "hide_me", "aTargets": [ 6,7,8 ] }],
      "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
            $('td:eq(5)', nRow).addClass( "text-right" );
        },
      "ajax":{
        url :"get-model-datatble.php", // json datasource
        async:false,
        dataType:'json',
        type: "post", // method , by default get
      }
    });

Thanks

  • 写回答

1条回答 默认 最新

  • weixin_33726318 2016-01-11 04:50
    关注

    Try this script

    var oTable = $('.dataTable').DataTable();
    oTable.fnPageChange(2,true);
    

    Or

    https://datatables.net/reference/option/displayStart

    Add the displayStart option

     var oTable = $('.dataTable').DataTable( {
          "processing": true,
          "serverSide": true,
          "bLengthChange": false,
          'iDisplayLength':5,
           "displayStart": 20,
          "bSort": false,// disable sort options
          "aoColumnDefs": [{ "bSortable": false, "aTargets": [ "_all" ],"sClass": "hide_me", "aTargets": [ 6,7,8 ] }],
          "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
                $('td:eq(5)', nRow).addClass( "text-right" );
            },
          "ajax":{
            url :"get-model-datatble.php", // json datasource
            async:false,
            dataType:'json',
            type: "post", // method , by default get
          }
        });
    
    评论

报告相同问题?