Bug in KeyTable fnSetPosition with defer render (DT 1.10)
Bug in KeyTable fnSetPosition with defer render (DT 1.10)
RagingTroll
Posts: 34Questions: 3Answers: 0
When setting position to a cell that is not yet rendered an error will be thrown
Problem in functions:
- _fnCellFromCoords - https://github.com/DataTables/KeyTable/blob/master/js/dataTables.keyTable.js#L871
- _fnFindDtCell - https://github.com/DataTables/KeyTable/blob/master/js/dataTables.keyTable.js#L978
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];
}
}
}
This discussion has been closed.
Replies
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