数据表js 1.9.4分页和搜索不适用于服务器端生成

时间:2014-09-19 13:28:41

标签: javascript php jquery ajax jquery-datatables

我使用数据表js 1.9.4并使用他们的ajax数据填充功能。当我以这种方式创建它们时,分页显示控件和搜索栏也存在,但都不起作用。 Alos数据表显示一页中的所有数据。

这是一代JS:

    $("#prop_table").dataTable({

            "aaSorting": [[2, "desc" ]],
            "sDom": "<'row'<'col-lg-9'l><'col-lg-3'f>r>t<'row'<'col-lg-5'i><'col-lg-7'p>>",
            "sPaginationType": "bootstrap",
            "bJQueryUI": false,
            "bAutoWidth": false,
            "aLengthMenu": [[5, 10, 25, -1], [5, 10, 25, "All"]],
            "iDisplayLength": 5,
            "oLanguage": {
                "sSearch": "<span></span> _INPUT_",
                "sLengthMenu": "<span>_MENU_</span>",
                "oPaginate": { "sFirst": "First", "sLast": "Last" }
            },
            "bProcessing": true,
            "iDisplayLength":5 ,
            "bServerSide": true,
            "sAjaxSource": "/php/api_prop_down.php",
            "aoColumns": [{
                "mData":"name"
              },{
                "mData": "time_down"
              },{
                "mData": "status_id"
              },{
                "mData": "button",
                "mRender": function(data){
                    if (data != "null" )
                        return "<button id=\"prop_issue"+data+"\" issue=\""+data+"\" class=\"btn\" data-toggle=\"modal\" data-target=\"#myModal\" onclick=\"getTicket("+data+")\">"+data+"</button>";
                    else 
                        return "no ticket";
                }
              }
            ]                      
        });
    $('.dataTables_length select').uniform();
    $('.dataTables_paginate > ul').addClass('pagination');
    $('.dataTables_filter>label>input').addClass('form-control');

    // Set the classes that TableTools uses to something suitable for Bootstrap
    $.extend( true, $.fn.DataTable.TableTools.classes, {
        "container": "btn-group",
        "buttons": {
            "normal": "btn",
            "disabled": "btn disabled"
        },
        "collection": {
            "container": "DTTT_dropdown dropdown-menu",
            "buttons": {
                "normal": "",
                "disabled": "disabled"
            }
        }
    } );

    // Have the collection use a bootstrap compatible dropdown
    $.extend( true, $.fn.DataTable.TableTools.DEFAULTS.oTags, {
        "collection": {
            "container": "ul",
            "button": "li",
            "liner": "a"
        }
    } );

我的服务器端脚本返回一个JSON,它是一个编码的php数组:

$output = array("sEcho" => intval($_GET['sEcho']),
    "iTotalRecords" => $count,
    "iTotalDisplayRecords" => 5,
    "aaData" => $aaData );

....

echo json_encode(propsDownJSON());

任何人都知道为什么会发生这种情况?

0 个答案:

没有答案