aoColumns & columnDefs
aoColumns & columnDefs
Hi,
i had 2 question
i'm try to use columnDefs to declare title and sorting element but i got this error " Uncaught TypeError: Cannot read property 'aDataSort' of undefined" in chrome debugger.
if i revert and i use "aoColumns" everything work, but i think aoColumns is legacy version (i use the 1.10.4 from maxcdn).
i need to associate an extra attribute to each column header, something like ' lang="xyz" ' to allow jquery-lang plugin to translate the column headers. how i con do it ? how i can add extra attributes to columns headers ?
thanks in advance
/stefano
Answers
Can you please link to a test case showing the issue, as required in the forum rules, so we can debug it.
You would need to use standard DOM or jQuery methods to do it - possibly in the
initComplete
callback. DataTables itself doesn't provide an option to add attributes to the created header cells.Allan
I had tried to recreate a test area but i fail because most of the page is composed by dynamic content for authenticate user. I have to recreate pages from scratch.
here is the snip of working code
noTable=$("#note").dataTable( {
"processing": true,
"ajax": "index.pl?mode=ajax&action=get&object=mynote&uid="+$("#uid").text(),
"paging": false,
"info": true,
"searching": true,
"ordering": true,
"order": [[ 1, "desc" ]],
"aoColumns": [
{ "target": 0, "sClass": "numero_class"},
{ "target": 1, "sClass": "date_class text"},
{ "target": 2, "sClass": "date_class text"},
{ "target": 3, "sClass": "value_class text"},
{ "target": 4, "sClass": "value_class text"},
{ "target": 5, "sClass": "value_class text"}],
but the same code with columnDefs give me the said error.
Btw, about adding some extra attr to the column titles, i move the column title from the DataTable definition into html <thead> from page source and i workaround the problem.