Bug in KeyTable fnSetPosition with defer render (DT 1.10)

Bug in KeyTable fnSetPosition with defer render (DT 1.10)

RagingTrollRagingTroll Posts: 34Questions: 3Answers: 0
edited May 2014 in Bug reports

When setting position to a cell that is not yet rendered an error will be thrown

Problem in functions:

My fix for _fnCellFromCoords:

var oData = _oDatatable.aoData[_oDatatable.aiDisplay[y]];
if (oData != null) {
 if (!oData.nTr) {
  _oDatatable.oApi._fnCreateTr(_oDatatable, y); //Create tr if is not yet created
 }
 return _oDatatable.aoData[ _oDatatable.aiDisplay[ y ] ].nTr.getElementsByTagName('td')[x];
}
else
{
 return null;
}

Fix and optimization for _fnCellFromCoords (instead of looping through all rows and cells, get the cell parent tr and get its property _DT_RowIndex. We have a complexity of O(num_column) instead of O(num_column*num_rows)):

var nTr = nTarget.parentNode;
if (nTr != null) {
 var nTds = nTr.getElementsByTagName('td');
 for ( var j=0, jLen=nTds.length ; j<jLen ; j++ )
 {
  if ( nTds[j] == nTarget )
  {
   return [j, nTr._DT_RowIndex];
  }
 }
}

Example:
http://live.datatables.net/delaroq/8/

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    KeyTable is going to get a rewrite soon. This error might be corrected by the changes that I need to DT core for the other bugs you've raised, but I'm not going to specifically target this bug due to the upcoming rewrite.

    Allan

This discussion has been closed.