【问题标题】:how to change page number datatable in outside datatable with jquery?如何使用jquery更改外部数据表中的页码数据表?
【发布时间】:2015-10-09 23:51:11
【问题描述】:

我将 DataTables 1.10.4 与 php 和 jquery 一起使用。 我想要带有 jquery 的页码表,但我的代码不起作用?请掌舵我?

$(function(){

        dTable  =   $('#allProductsTbl').DataTable({
            "aLengthMenu": [[1, 50, 100, -1], [20, 50, 100, "همه"]],
            "responsive": true,
            "language": {
                "url": "../data/include/public/Persian.json"
            },
            "processing": true,
            "serverSide": true,
            "ajax":"products/op/dt_processing.php"
        });
        dTable.order( [ 3, 'desc' ] ).draw();
        //alert('pageNumber:'+dTable.page());
       dTable.page(3).draw(false);

    });

【问题讨论】:

  • 我有问题

标签: php jquery datatables


【解决方案1】:

解决方案

使用page() API 方法设置表格的当前页。请注意,页码从零开始,因此 page(3) 打开第 4th 页。

例如:

$('#allProductsTbl').on('xhr.dt', function ( e, settings, json ) {
   var api = new $.fn.dataTable.Api(settings);
   api.page(3).draw(false);
});

var dTable = $('#allProductsTbl').DataTable({
   "aLengthMenu": [[1, 50, 100, -1], [20, 50, 100, "همه"]],
   "responsive": true,
   "language": {
      "url": "../data/include/public/Persian.json"
   },
   "processing": true,
   "serverSide": true,
   "ajax":"products/op/dt_processing.php",
   "order": [[ 3, 'desc' ]]
});

演示

请参阅this jsFiddle 进行演示。

【讨论】:

  • @AliNasiri,添加了演示页面的链接。
  • 谢谢你。再次不起作用。我改变了我的代码。请帮帮我
  • @AliNasiri,它不起作用,因为现在您有 Ajax 请求。我可以更新答案,但您为什么要转到特定页面?
  • @AliNasiri,抱歉,这是一个错字,现在已更正。
  • “page(3) 打开第 4 页。”帮帮我,谢谢。
猜你喜欢
  • 2020-05-01
  • 2017-12-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多