DataTables warning:table id=DataTables_Table_0 - Requested unknown parameter '0' for row 0, column 0

DataTalbes报错系列(二)
持续采坑中…,

报错内容

DataTables warning: table id=DataTables_Table_0 - Requested unknown parameter '0' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4

DataTables warning:table id=DataTables_Table_0 - Requested unknown parameter '0' for row 0, column 0_第1张图片

报错解决方案

未设置行细节,也就是未配置 columns参数

  1. ,如果服务端返回的 Data字段为 字符串数组形式,可以不配置行细节(Columns),比如如下形式:
    官网实例参考:https://datatables.net/examples/server_side/simple.html
{
  "draw": 1,
  "recordsTotal": 57,
  "recordsFiltered": 57,
  "data": [
    [
      "Airi",
      "Satou",
      "Accountant",
      "Tokyo",
      "28th Nov 08",
      "$162,700"
    ],
    [
      "Angelica",
      "Ramos",
      "Chief Executive Officer (CEO)",
      "London",
      "9th Oct 09",
      "$1,200,000"
    ]
  ]
}
  1. 但是如果 data字段返回为 Json 价值对形式,那就需要配置行细节, 比如以下:
    官网实例参考:https://datatables.net/examples/server_side/row_details.html
{
  "draw": 1,
  "recordsTotal": 57,
  "recordsFiltered": 57,
  "data": [
    {
      "DT_RowId": "row_5",
      "first_name": "Airi",
      "last_name": "Satou",
      "position": "Accountant",
      "office": "Tokyo",
      "start_date": "28th Nov 08",
      "salary": "$162,700"
    },
    {
      "DT_RowId": "row_25",
      "first_name": "Angelica",
      "last_name": "Ramos",
      "position": "Chief Executive Officer (CEO)",
      "office": "London",
      "start_date": "9th Oct 09",
      "salary": "$1,200,000"
    }]
}

你可能感兴趣的:(web开发,JQuery,JQuery,DataTables,插件实例详解)