Sorting and Filtering broken after column reordering
Sorting and Filtering broken after column reordering
Ironwil616
Posts: 50Questions: 0Answers: 0
In another thread I posted that, after a column was moved or hidden, sorting and filtering no longer worked correctly. I've found the reason. In the '_fnColumnOptions' function, two functions are set with 'mDataProp':
[code]
/* Cache the data get and set functions for speed */
oCol.fnGetData = _fnGetObjectDataFn(oCol.mDataProp);
oCol.fnSetData = _fnSetObjectDataFn(oCol.mDataProp);
[/code]
'mDataProp' is the index of the column to be filtered, sorted, etc. When the '_fnGetObjectDataFn(mSource)' function runs, instead of using the current index of the column, the cached index is used instead. I found the source of the problem, but I'm still unsure how to fix it. In the '_fnGetCellData' function, 'sData' is assigned to like this:
[code]
if ((sData = oCol.fnGetData(oData)) === undefined)
[/code]
I'm also confused by the fact that 'oData' is an entire row, not an index. Stepping through the code wasn't very enlightening. I jumped straight to the end of '_fnGetObjectDataFn', which has a parameter of 'mSource', already assigned to with the index. I was skipped over all the code running in between. Might be a limitation of my IDE. So, I'm not sure where the assignment is taking place, unless it's in the two lines of code above. In the 'oCol' object, the original column index is stored in 'oCol._ColReorder_iOrigCol' and in 'mDataProp'. The new index is stored in 'iDataSort'. Unfortunately, the 'mDataProp' is being used for sorting and filtering, even after a column has been moved, so of course there will be no results.
So, without an easy way to alter the column index stored in the '_fnGetObjectDataFn' function, sorting and filtering are broken when the ColReorder or ColVis plugins are used, unless I'm missing something.
[code]
/* Cache the data get and set functions for speed */
oCol.fnGetData = _fnGetObjectDataFn(oCol.mDataProp);
oCol.fnSetData = _fnSetObjectDataFn(oCol.mDataProp);
[/code]
'mDataProp' is the index of the column to be filtered, sorted, etc. When the '_fnGetObjectDataFn(mSource)' function runs, instead of using the current index of the column, the cached index is used instead. I found the source of the problem, but I'm still unsure how to fix it. In the '_fnGetCellData' function, 'sData' is assigned to like this:
[code]
if ((sData = oCol.fnGetData(oData)) === undefined)
[/code]
I'm also confused by the fact that 'oData' is an entire row, not an index. Stepping through the code wasn't very enlightening. I jumped straight to the end of '_fnGetObjectDataFn', which has a parameter of 'mSource', already assigned to with the index. I was skipped over all the code running in between. Might be a limitation of my IDE. So, I'm not sure where the assignment is taking place, unless it's in the two lines of code above. In the 'oCol' object, the original column index is stored in 'oCol._ColReorder_iOrigCol' and in 'mDataProp'. The new index is stored in 'iDataSort'. Unfortunately, the 'mDataProp' is being used for sorting and filtering, even after a column has been moved, so of course there will be no results.
So, without an easy way to alter the column index stored in the '_fnGetObjectDataFn' function, sorting and filtering are broken when the ColReorder or ColVis plugins are used, unless I'm missing something.
This discussion has been closed.
Replies