Quantcast
Channel: DataTables 1.9 — DataTables forums
Viewing all articles
Browse latest Browse all 124

Filtering combined with custom sort function (dataTableExt.afnSortData) removes valid rows from tabl

$
0
0
I am using a custom sort function ($.fn.dataTableExt.afnSortData), which works fine by itself. E.g. the sort function returns a date in the form 20140428, where the table itself shows dates in a formatted layout, such as April 28th, 2014; optionally including html.
I can correctly sort on the column and I can correctly filter on the date by entering "April" in the search field.

However, if I combine these actions by
* Entering April in the search field (this correctly filters out the other rows)
* Then sorting on the date column

And then I see that the results of "April" are filtered out from the result.

Is it possible that this is caused by _fnSetCellData in line 3960-3976 in jquery-dataTables-1.9.4 where the data is updated by _fnSetCellData?

if ( DataTable.ext.afnSortData[sDataType] ) { var aData = DataTable.ext.afnSortData[sDataType].call( oSettings.oInstance, oSettings, iColumn, iVisColumn ); if ( aData.length === aoData.length ) { for ( j=0, jLen=aoData.length ; j<jLen ; j++ ) { _fnSetCellData( oSettings, j, iColumn, aData[j] ); } } else { _fnLog( oSettings, 0, "Returned data sort array (col "+iColumn+") is the wrong length" ); } }
If I alter the sort function to concatenate the formatted date, the unexpected filtering by sorting doesn't happen, which seems to validate the assumption that the data used by the filtering is updated by the sort method.

Is there anything I can do in the sort method or datatable to fix this, or should I file a bug for this?

Viewing all articles
Browse latest Browse all 124

Trending Articles