DataTables warning requested unknown parameter
This is possibly the most cryptic warning message that DataTables will show. It is a short error message as it needs to cope with all of the data source options that DataTables has, but flexible enough to convey information for each of these cases, hence why it can appear a little cryptic on first inspection. However, when we break it down into its component parts, it is actually relatively straight forward, as described below.
Meaning
Each cell in DataTables requests data, and when DataTables tries to obtain data for a cell and is unable to do so, it will trigger a warning, telling you that data is not available where it was expected to be. The warning message is:
DataTables warning: table id=
{id}
- Requested unknown parameter '{parameter}
' for row{row-index}, column
{column-index}`
where:
{id}
is replaced with the DOM id of the table that has triggered the error{parameter}
is the name of the data parameter DataTables is requesting{row-index}
is the DataTables internal row index (row().index()
) for the row that has triggered the error.{column-index}
is the column data index (column().index()
) for the column that has triggered the error. The column index information was added in DataTables 1.10.10.
So to break it down, DataTables has requested data for a given row, of the {parameter}
provided and there is no data there, or it is null
or undefined
(DataTables doesn't know, by default how to display these parameters - see below if your data does contain these values).
Diagnosis
The key part to understanding this error message is the {parameter}
aspect of it. It will be in one of three forms:
- Integer
- String
- Function
Parameter is an integer
When {parameter}
is an integer, DataTables is looking for data from an array. This is usually the case when using DOM sourced data (i.e. the data for the table is read automatically from the document). In this circumstance the requested data doesn't exist in source array - likely because the array isn't long enough. This can occur if:
- There is a
colspan
orrowspan
in thetbody
of the table, which is not supported by DataTables. - Using
columns
orcolumnDefs
you have specified more columns than there are in the HTML - The number of cells in the table does not satisfy the equation
#cells = #columns * #rows
(i.e. there are more columns defined in the header than in the table body, or vice-versa).
Parameter is a string
If {parameter}
is shown as a string, this will typically indicate that you have used columns.data
or columns.render
to pull data out of an object, be it Ajax loaded or from the client-side. For example the error message in read: Requested unknown parameter 'Name' for row 0. This will indicate that a column which uses columns.data
has been unable to obtain valid data to display - for example:
1
|
{ data: 'Name' } |
would produce this error if the data source object for the row had no Name
parameter or the data wasnull
or undefined
.
As a result, this error usually occurs if:
- The data property specified doesn't exist (a typo or a gap in data)
- The value of the property specified is null
Parameter is a function
If {parameter}
simply says {function} it means that columns.data
or columns.render
have been given as a function, but the function has returned null
or undefined
. For example, the following would trigger such an error:
1
2
3
4
5
|
{ data: function ( row, type, set ) { if ( type === 'display' ) { return row.Name; } } ); |
Note how the return statement is only used when type === 'display'
. As a result, if type
is notdisplay then undefined
is the return value from the function and DataTables will throw a warning.
Resolution
The key to resolving this error, is to ensure that DataTables has all of the data that is required. Specifically, check the following:
colspan
androwspan
have not been used in thetbody
of the table.- The equation
#cells = #columns * #rows
is satisfied. - If using
columns
ensure that you have specified exactly the number of columns that are present in the HTML for the table. - Also if using `dt-init columns, remove any trailing commas you might have at the end of the array. The additional comma can cause issues for older browsers.
- If using dt-init columnDefs` ensure that you have not specified more columns than there are in the HTML
- If using
columns.render
orcolumns.data
ensure that they are returning a value (no return in Javascript is the same as returningundefined
which will result in this error). - Ensure that the server-side script is completing its execution successfully. Long running scripts can time out for example. The server error logs will give an indication if this is the case.
null
or undefined
data
null
and undefined
values in a data source absolutely are valid and very often useful. DataTables warns about the use of them by default, as the majority of the time they are not intended for display - for example, rather than showing null in the table, you might want to show Not yet set, or simply an empty string (empty cell). For this, DataTables has a columns.defaultContent
option.
With columns.defaultContent
set, any null
or undefined
value will be replaced with the value specified. No warning will be shown in this circumstances.
DataTables warning requested unknown parameter的更多相关文章
- DataTables warning : Requested unknown parameter '5' from the data source for row 0
在该项目中我使用了jquery.dataTables.js来作为我的前端数据表格. 表格的官网地址:https://www.datatables.net/ 一.jsp部分代码片段如下: <tab ...
- DataTables warning : Requested unknown parameter '0' from the data source for row 0错误
在做datatables的项目,从后台取得数据后,返回给datatables界面时会报下面的错误: DataTables warning : Requested unknown parameter ' ...
- Jquery DataTables warning : Requested unknown from the data source for row 0
昨天在做 Jquery DataTables 的时候,遇到的一个问题,我使用MVC,在tables上加入了一个actionlink的href.但是在运行起来的时候,报错: DataTables war ...
- DataTables warning: table id=data-table - Requested unknown parameter '3' for row 0.
本文为博主原创,未经允许,不得转载: 在使用jquery 的datatable时,报错在页面弹出弹出框,并提示以下内容: DataTables warning: table id=data-table ...
- DataTables warning: table id=dataTable - Requested unknown parameter 'acceptId' for row 0. For more
重点内容 DataTables warning: table id=dataTable - Requested unknown parameter 'acceptId' for row 0. For ...
- DataTables warning (table id = 'myTable'): Requested unknown parameter '0' from the data source for row 0
第一种方式:不用在js里设置列Html: <table id="myTable"> <thead> <tr> <th>Title-1 ...
- DataTables warning: table id=DataTables_Table_0 - Requested unknown parameter '1' for row 0. For more information about this error, please see http://datatables.net/tn/4
今天在做后台的时候,考虑到会员模块和订单模块列表显示差不多,于是乎,偷了个懒,把会员列表显示页面的代码拷贝了过来,修改了一下,变成了订单模块.可是,在订单列表显示的时候老是报下面的错误,截图如下: 后 ...
- Warning: in_array() expects parameter 2 to be array, string given in D:\wamp\www\suiji.php on line 26
可参考上篇文章 链接 PHP数组简写模式 同样是PHP版本问题:in_array()函数 第二个参数应该为数组 但是 lnmp下,PHP5.3不报错,wamp下PHP5.5报以下错误: echo & ...
- Unknown parameter datatype UNKNOW send from server.
procedure Tmainform.Button7Click(Sender: TObject); begin kbmMWClientQuery3.Query.Text:='insert into ...
随机推荐
- tornado框架基础02-输入和输出
01 输出 write bytes类型 class IndexHandler(tornado.web.RequestHandler): def get(self): self.write(b'Torn ...
- 南邮CTF--SQL注入题
南邮CTF--SQL注入题 题目:GBK SQL injection 解析: 1.判断注入点:加入单引号发现被反斜杠转移掉了,换一个,看清题目,GBK,接下来利用宽字节进行注入 2.使用'%df' ' ...
- CentOS 6.5 x64 安装MySql 5.6
1.检测是否已经安装MySQL,输入以下命令 rpm -qa | grep mysql 如果存在,我们输入以下命令来删除 //强力删除 rpm -e --nodeps mysql 2.安装前环境准备 ...
- Android开发——程序锁的实现(可用于开发钓鱼登录界面)
1. 程序锁原理 1.1 实现效果: 在用户打开一个应用时,若此应用是我们业务内的逻辑拦截目标,那就在开启应用之后,弹出一个输入密码的界面,输入密码正确则进入目标应用.若不输入直接按返回键,则直接返回 ...
- CSUOJ 1256 天朝的单行道
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1256 题目大意: 在另一个平行宇宙中,有一个神奇的国度名叫天朝.天朝一共有N个城 ...
- BZOJ 1303: [CQOI2009]中位数图 【水题】
给出1~n的一个排列,统计该排列有多少个长度为奇数的连续子序列的中位数是b.中位数是指把所有元素从小到大排列后,位于中间的数. Input 第一行为两个正整数n和b ,第二行为1~n 的排列. Out ...
- HDU 1558
输入线段的两个短点,如果线段相交那么他们属于一个集合,查看第i条线段所在的集合有几条线段. 好久没码码了,总是各种蠢. 首先找出两条直线的方程,求解相交点的横坐标,然后看是不是在线段内部. 没有注意题 ...
- spring/spring boot/spring mvc中用到的注解
在spring Boot中几乎可以完全弃用xml配置文件,本文的主题是分析常用的注解. Spring最开始是为了解决EJB等大型企业框架对应用程序的侵入性,因此大量依靠配置文件来“非侵入式”得给POJ ...
- 转 常见hash算法的原理
散列表,它是基于快速存取的角度设计的,也是一种典型的“空间换时间”的做法.顾名思义,该数据结构可以理解为一个线性表,但是其中的元素不是紧密排列的,而是可能存在空隙. 散列表(Hash table,也叫 ...
- 阿里oss上传图片react组件alioss-react,vue组件alioss-vue (不用我先收藏着,后端看下前端处理方法)
1.介绍 最近开发了一个项目,其中需要一个上传图片到阿里云的 oss 上面,就是上传图片到阿里云的 oss 上面. 因为之前开发过 vue 的阿里云 oss 上传,所以直接复制粘 vue 的组件. 因 ...