aoColumns in table header
aoColumns in table header
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.
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.
This discussion has been closed.
Replies
You simply need to read your attributes etc and construct an aoColumns object _before_ the table initialisation, rather than after it.
Allan