aoColumns in table header

aoColumns in table header

AlexanderAlexander Posts: 17Questions: 0Answers: 0
edited December 2012 in General
To begin with I want to thank you for a great plugin.
I use it for few years and everything suit.
Now I need to aoColumns defined in table header.
I do so:
[code]
oTable=$('#table').dataTable( {
"sAjaxSource": "table.json",
"sPaginationType": "full_numbers" ,
"aaSorting": [[2,'desc']],
} );
var columns=oTable.fnSettings().aoColumns;
$('#table thead th').each(function(i){
if(typeof $(this).attr('bSortable')!='undefined')columns[i].bSortable=$(this).attr('bSortable');
if(typeof $(this).attr('sType')!='undefined')columns[i].sType=$(this).attr('sType');
if(typeof $(this).attr('sClass')!='undefined')columns[i].sClass=$(this).attr('sClass');
});
[/code]
The problem is that the sType is not defined in this way.
Column sorting as default type.
But if you define sType in the table initialization, then everything works correctly.
What do i do wrong?
thanks.

Replies

  • allanallan Posts: 63,530Questions: 1Answers: 10,473 Site admin
    You cannot change the settings after initialisation - that's a private property and there is no hook to tell DataTables that things have changed. It would probably double the code size if there was.

    You simply need to read your attributes etc and construct an aoColumns object _before_ the table initialisation, rather than after it.

    Allan
  • AlexanderAlexander Posts: 17Questions: 0Answers: 0
    understood, thanks a lot.
This discussion has been closed.