iTabIndex initialization
iTabIndex initialization
adelaidetrabuco
Posts: 4Questions: 0Answers: 0
I wanted to initialize the iTabIndex of my table with -1 if the column isn't sortable. I used the code:
$('#example').dataTable( {
"iTabIndex": -1
} );
But it didn't work because he is always initializing the column tabindex with 0 because it hits the else of the following function:
function _fnBuildHead( oSettings ) {
...
var iThs = $('th, td', oSettings.nTHead).length;
...
/* If there is a header in place - then use it - otherwise it's going to get nuked... */
if ( iThs !== 0 ) {
/* We've got a thead from the DOM, so remove hidden columns and apply width to vis cols */
for ( i=0, iLen=oSettings.aoColumns.length ; i
$('#example').dataTable( {
"iTabIndex": -1
} );
But it didn't work because he is always initializing the column tabindex with 0 because it hits the else of the following function:
function _fnBuildHead( oSettings ) {
...
var iThs = $('th, td', oSettings.nTHead).length;
...
/* If there is a header in place - then use it - otherwise it's going to get nuked... */
if ( iThs !== 0 ) {
/* We've got a thead from the DOM, so remove hidden columns and apply width to vis cols */
for ( i=0, iLen=oSettings.aoColumns.length ; i
This discussion has been closed.
Replies
The table index is set only once and is only used for columns which are sortable. At no time, now, does it set `0` as the tab index (which was wrong).
Allan
In the mean while I did a workaround:
$('#example').dataTable( {
"fnInitComplete": function(oSettings, json) {
$.each($(this).find('th'), function (i, th) {
$.each(oSsettings.aoColumns, function (i, column) {
if ($(column.nTh).text() == $(th).text()) {
if (!column.bSortable) {
$(th).attr('tabindex', '-1');
}
}
});
})