iTabIndex initialization

iTabIndex initialization

adelaidetrabucoadelaidetrabuco Posts: 4Questions: 0Answers: 0
edited August 2013 in Bug reports
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

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    I've already committed some changes in this area for DataTables 1.10 (which is pre-beta): https://github.com/DataTables/DataTables/tree/1_10_wip/media/js

    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
  • adelaidetrabucoadelaidetrabuco Posts: 4Questions: 0Answers: 0
    Thanks 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');
    }
    }
    });
    })
This discussion has been closed.