fnGetCurrentPosition and fnSetPosition index mismatch when using RowGrouping
fnGetCurrentPosition and fnSetPosition index mismatch when using RowGrouping
With version 1.1.7, if I set an event to call fnGetCurrentPosition on click and I click on the topmost cell, it returns 1.
The cell that fnSetPosition refers to as 0, fnGetCurrentPosition refers to as 1.
Easy enough to overcome, but seems like they would both be either 0-index based or 1-index based.
To make matters more interesting, if you click on that cell and then press Shift (or any other key that triggers _fnKey past the 2nd if block) then it recalculates things and fnGetCurrentPosition then returns 0!
I solved this by copying the appropriate coordinate update code that ran when shift was executed. I am using RowGrouping and I am thinking the mismatch comes from one fcn (most likely _fnSetFocus) counting the row groups and the other not. The code that follows is line for line ripped from fnKey and placed into the end of fnClick.
[code]
// Refresh coordinates
if ( _oDatatable )
{
/*
* Locate the current node in the DataTable overriding the old positions - the reason for
* is is that there might have been some DataTables interaction between the last focus and
* now
*/
var aDtPos = _fnFindDtCell( _nOldFocus );
if ( aDtPos === null )
{
/* If the table has been updated such that the focused cell can't be seen - do nothing */
return;
}
_iOldX = aDtPos[ 0 ];
_iOldY = aDtPos[ 1 ];
}[/code]
The cell that fnSetPosition refers to as 0, fnGetCurrentPosition refers to as 1.
Easy enough to overcome, but seems like they would both be either 0-index based or 1-index based.
To make matters more interesting, if you click on that cell and then press Shift (or any other key that triggers _fnKey past the 2nd if block) then it recalculates things and fnGetCurrentPosition then returns 0!
I solved this by copying the appropriate coordinate update code that ran when shift was executed. I am using RowGrouping and I am thinking the mismatch comes from one fcn (most likely _fnSetFocus) counting the row groups and the other not. The code that follows is line for line ripped from fnKey and placed into the end of fnClick.
[code]
// Refresh coordinates
if ( _oDatatable )
{
/*
* Locate the current node in the DataTable overriding the old positions - the reason for
* is is that there might have been some DataTables interaction between the last focus and
* now
*/
var aDtPos = _fnFindDtCell( _nOldFocus );
if ( aDtPos === null )
{
/* If the table has been updated such that the focused cell can't be seen - do nothing */
return;
}
_iOldX = aDtPos[ 0 ];
_iOldY = aDtPos[ 1 ];
}[/code]
This discussion has been closed.