将sPagination添加到我的jQuery数据表脚本会导致它停止工作

时间:2014-04-22 17:39:04

标签: javascript jquery ajax datatables

如果没有这一行运行下面的代码:

   "sPaginationType": "RequestID",

代码可以工作,但是当添加该行时,我们遇到以下错误:

TypeError:DataTable.ext.oPagination [oSettings.sPaginationType]未定义

我确实在页面顶部定义了paginator库:

  <script type="text/javascript" language="javascript" src="js/dataTables.jPaginator.js"></script>

我还缺少什么?

 <script type="text/javascript">
$(document).ready(function() {
    /* Init DataTables */
$("#examples").dataTable( {
    "bProcessing" : true,
    "sPaginationType": "RequestID",
    // Commenting out next line
    //"sDom" : 't',
    "sAjaxSource" : "phpservices/getUserDetails.php?loginName=" + UserName,
    "sAjaxDataProp" : "",
    "bDestroy" : true,
    "fnServerData" : function(sSource, aoData, fnCallback) {
        request = $.ajax({
            "dataType" : "json",
            "type" : "GET",
            "url" : sSource,
            "data" : aoData,
            "success" : fnCallback
        });
    },
         "aoColumns" : [
          { mDataProp: "RequestID", bSortable: true },
          { mDataProp: "RequestDate", bSortable: true },
          { mDataProp: "RequestorFullName", bSortable: true },
          { mDataProp: "PrimarySiteContactDisplay", bSortable: true },
          { mDataProp: "RequestLocation", bSortable: true },
          { mDataProp: "RequestDescription", bSortable: true },
          { mDataProp: "RequestStatus", bSortable: true },
        ],
      })
   });
</script>

1 个答案:

答案 0 :(得分:0)

我已经解决了这个问题。

我忽略了将sPagination改为bPagination,与const定义一致。

"sbPaginationType": "RequestID",

"bPaginationType": "RequestID",