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

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/shuai_wy/article/details/82831811

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

JQuery DataTables

报错解决方案

未设置行细节,也就是未配置 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"
    }]
}

猜你喜欢

转载自blog.csdn.net/shuai_wy/article/details/82831811