数据表显示通过服务器json提供数据时的所有记录而不是分页

时间:2015-04-01 18:16:44

标签: php mysql ajax datatables

这是我的json输出。

{
    "draw": 0,
    "recordsTotal": 130,
    "recordsFiltered": 130,
    "data": [
        {
            "order_id": "32",
            "location_address": "XYZ road Delhi delhi",
            "order_status": "0",
            "created_by": "5",
            "from_date": "Mar-30-2015",
            "emp_name": " ",
            "actions": "\r\n\t\t\t\t\t<a onclick=\"show_edit()\" class=\"btn default btn-xs purple \">\r\n                                               <i class=\"fa fa-edit\" ></i> Edit </a>"
        },
        {
            "order_id": "33",
            "location_address": "XYZ road Delhi delhi",
            "order_status": "0",
            "created_by": "5",
            "from_date": "Mar-30-2015",
            "emp_name": " Ranjeet thakur, abhijeet thakur",
            "actions": "\r\n\t\t\t\t\t<a onclick=\"show_edit()\" class=\"btn default btn-xs purple \">\r\n                                               <i class=\"fa fa-edit\" ></i> Edit </a>"
        },
        {
            "order_id": "34",
            "location_address": "XYZ road Delhi delhi",
            "order_status": "0",
            "created_by": "5",
            "from_date": "Mar-31-2015",
            "emp_name": " ",
            "actions": "\r\n\t\t\t\t\t<a onclick=\"show_edit()\" class=\"btn default btn-xs purple \">\r\n                                               <i class=\"fa fa-edit\" ></i> Edit </a>"
        },
        {
            "order_id": "35",
            "location_address": "XYZ road Delhi delhi",
            "order_status": "0",
            "created_by": "5",
            "from_date": "Mar-31-2015",
            "emp_name": " super Employee",
            "actions": "\r\n\t\t\t\t\t<a onclick=\"show_edit()\" class=\"btn default btn-xs purple \">\r\n                                               <i class=\"fa fa-edit\" ></i> Edit </a>"
        },
        {
            "order_id": "36",
            "location_address": "XYZ road Delhi delhi",
            "order_status": "0",
            "created_by": "5",
            "from_date": "Mar-31-2015",
            "emp_name": " ",
            "actions": "\r\n\t\t\t\t\t<a onclick=\"show_edit()\" class=\"btn default btn-xs purple \">\r\n                                               <i class=\"fa fa-edit\" ></i> Edit </a>"
        }
    ]
}

“pageLength”:10(它应该在一个页面上显示10条记录。)

仍然在一页上显示130条记录。但我想在一个页面上显示10条记录..那么我该如何显示..?

插件初始化: -

dataTable: { 
                "lengthMenu": [
                    [10, 20, 50, 100, 150, -1],
                    [10, 20, 50, 100, 150, "All"] 
                ],
                "pageLength": 10,
    aoColumns: [
    { mData: 'order_id'},
    { mData: 'user_name'},
    { mData: 'location_address'},
    { mData: 'from_date'},
    { mData: 'assign_to'},
       { mData: 'order_status'},
    { mData: 'actions'}
    ],

"ajax": {
                    "url": page.php,
                }

0 个答案:

没有答案