Is it possible to set columnDefs with global setting and also has independent setting?
Is it possible to set columnDefs with global setting and also has independent setting?
Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
I would like to have this global setting for all datatables
$.extend(true, $.fn.dataTable.defaults, {
columnDefs: [
{
targets: '_all',
defaultContent: '-'
}
]
});
And I also need independent setting for a single page
{ targets: [0, 1], visible: true},
why the independent setting make the global setting invalid?
This question has an accepted answers - jump to answer
Answers
The global setting was used to fix this error
DataTables warning: table id=ActionNominationList - Requested unknown parameter '11' for row 0, column 11. For more information about this error, please see http://datatables.net/tn/4
Not sure why we got the above error, but the global setting for defaultContent can fix it.
If you want to set a default for all columns, for all tables on the page use
Example: https://live.datatables.net/nowaqifu/1/edit
Allan
Hi @allan,
Tried an sample with empty data, but the plugin does not trigger such kind error
https://live.datatables.net/nowaqifu/6/edit
I use the global setting to fix this issue, but actually I have no idea why I got such kind of error. And there is no empty data in my environment, I am not sure how to reproduce it.
https://stackoverflow.com/questions/16539578/datatables-warning-requested-unknown-parameter-0-from-the-data-source-for-row
Without a test case showing the issue, I can't say exactly why it would be happening.
Allan
Hi @allan ,
Tried to reproduce with same data and setting, except the serverside setting. Can not reproduce it when not set serverside.https://live.datatables.net/pasemubi/4/edit
I would like to reproduce the error "Requested unknown parameter '11' for row 0, column 11."
But I have no idea how can I upload a data file as the ajax source, I have submit another issue about file upload issue https://datatables.net/forums/discussion/77763/how-can-i-upload-my-own-data-to-live-datatables-net-for-ajax-usage#latest
There is no
Details
property in the object. You aren't getting the "unknown parameter" error in that example because you do provide a renderer for that column. Remove therender
option and it would throw exactly the error you mention.Since there is no
Details
property, what you should do is usenull
as thecolumns.data
option:Possibly you were seeing the error even with the rendering function due to a different version of DataTables or perhaps the use of the API on your page is different.
Allan
Hi @allan,
I add the details for test purpose, and it does not break the test.
And finally I notice that I am using a wrong js file.https://github.com/ChuckTest/DataTablesTest/blob/wrong/jquery.dataTables-1.13.6.min.js
The sha of this file is SHA-512: 78a1380ff6558e92a0eaec78ef6ff463286330604beb4c78d32df2f8bf00f81aa822ec9f60b39d341a368d5f0aec63fb15693bb1a3c674674eafb6a6af8db6cb
However I can not figure out where I get the wrong files, the link https://datatables.net/download/#bs4/jszip-3.10.1/pdfmake-0.2.7/dt-1.13.6/af-2.6.0/b-2.4.2/b-colvis-2.4.2/b-html5-2.4.2/b-print-2.4.2/date-1.5.1/r-2.5.0 in file can only download the latest verion of combined js
I can reproduce the above error here, https://github.com/ChuckTest/DataTablesTest/tree/wrong, on wrong branch. Open the index.cshtml it will popup the error.
Do you have a file sha-512 list? then I can try seach the sha-512 to find where I got the wrong files.
I have confirmed this issue can be reproduced with the js file downloaded from https://datatables.net/download/#bs4/jszip-3.10.1/pdfmake-0.2.7/dt-1.13.8/af-2.6.0/b-2.4.2/b-colvis-2.4.2/b-html5-2.4.2/b-print-2.4.2/date-1.5.1/r-2.5.0
The files required for the link and script tags shown above can be downloaded using the button below. The package is downloaded as a zip file which should be unzipped and uploaded to your web-server.
The js file in zip file does not work, I will file another discussion