Jquery Datatable 数据填充报错:requested unknown parameter ‘XXX‘ for row xx, column xx 解决方法
前些天發(fā)現(xiàn)了一個巨牛的人工智能學(xué)習(xí)網(wǎng)站,通俗易懂,風(fēng)趣幽默,忍不住分享一下給大家。點(diǎn)擊跳轉(zhuǎn)到教程。
報錯如圖:
?
解決方法見官網(wǎng):https://datatables.net/manual/tech-notes/4
?
摘要如下:
?
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?or?rowspan?in the?tbody?of the table, which is not supported by DataTables.
- Using?columns?or?columnDefs?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).
- ?
在我的代碼里就是這種情況,參數(shù)為Integer 類型。還有參數(shù)為:String 、 function 類型的見官網(wǎng)解決方法。
解決方法摘要如下 :
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?and?rowspan?have not been used in the?tbody?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?or?columns.data?ensure that they are returning a value (no return in Javascript is the same as returning?undefined?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.
?
官網(wǎng)解決 例子:https://datatables.net/reference/option/columns.defaultContent
摘要如下:
這個例子對于我這種情況(參數(shù)為Integer 且為 null )的解決方法就是給該值設(shè)置 默認(rèn)值。 ?如圖在代碼中加上?" defaultContent " : ?" " ? 就OK了。默認(rèn)值的具體內(nèi)容可以自由設(shè)置。
?
?
?
總結(jié)
以上是生活随笔為你收集整理的Jquery Datatable 数据填充报错:requested unknown parameter ‘XXX‘ for row xx, column xx 解决方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 在User Control 中使用 Cu
- 下一篇: Oracle Long类型转换为Clob