DataTables/DataTables — Issue #43: Incorrect / inconsistent value used for filtering before / after sorting applied.
Author: re5et
Created: 2012-01-16 19:11:44+00:00
State: open

I have a custom sort in use in a table (pulling a value from a data attribute), and after a table has been sorted on one of these columns, if I attempt to filter, the value used for any column that has been sorted by this custom attribute is used instead of the text in the table cell. The filtering behavior only changes if the column has already been sorted. For example, with the following custom sort:

```javascript
// accessor for extracting cell sort data from data attribute
jQuery.fn.dataTableExt.afnSortData['dom-data'] = function(oSettings, iColumn){
var aData = [];
$( 'td:eq('+iColumn+')', oSettings.oApi._fnGetTrNodes(oSettings) ).each( function () {
aData.push( $(this).data('sort') );
});
return aData;
};
```
And the following table:

```html

Name
Time

Joe
abc

Bob
bcd

```

After the initial instantiation, done like so:

```javascript
$('#my-table').dataTable({
"aoColumns": [null, { "sSortDataType": "dom-data", "sType": 'numeric' }]
});
```

Filtering works as expected, typing "bc" shows both rows, "abc" shows only the first row, "bcd" shows only the second row.

After sorting by the "Time" column, the filtering examples shown above do not work. After this sort, the filtering seems to be using the sort values instead of the text values in the tds, because I can filter by "9476" and the first row will remain.

I assume that this is a bug because the behavior is inconsistent. If it is not, can you please explain how I can get the behavior I want, where the sorting goes by my custom sort, but the filter goes by the text in the td?