Column filtering on columns to the right of hidden columns not working
Column filtering on columns to the right of hidden columns not working
nicsoft
Posts: 37Questions: 0Answers: 0
I am using column filtering according to this example: http://datatables.net/release-datatables/examples/api/multi_filter.html
It works well for all my column except one that has dates of format 2012-05-25 15:41:35. When entering '2', all columns are filtered away, but all should remain in the table.
This column is the right most one. Between this and the other visible columns to the left I have two hidden columns. Like this:
[col1 (visible)][col2 (visible)]......[col 8 (hidden)][col 9 (hidden)][col 10 - Date]
When making col 9 visible (using ColVis), then it works. Entering '2' makes all rows still being present in the table (all starts on 2012).
To verify that the problem has to do with ColVis and not the actual date-column I changed the column visibility like this:
[col1 (visible)][col2 (visible)]......[col 8 (hidden)][col 8 (hidden)][col 9 (visible)][col 10 - Date]
Now, trying to filter on col 9 shows the same symptoms. I.e., entering 'k' if many rows starts on 'k' filters those away and leaves the table empty.
Is this a known issue? Does anyone know how to fix this?
Just in case this can have any importance for the problem:
[code]"aoColumnDefs": [
{ "asSorting": [ "desc", "asc", "desc" ], "aTargets": [ 0 ] },
{ "sWidth": "55px", "aTargets": [ 0 ] },
{ "sWidth": "65px", "aTargets": [ 1 ] },
{ "sWidth": "140px", "aTargets": [ 2 ] },
{ "sWidth": "100px", "aTargets": [ 3 ] },
{ "sWidth": "100px", "aTargets": [ 4 ] },
{ "sWidth": "85px", "aTargets": [ 5 ] },
{ "sWidth": "140px", "aTargets": [ 6 ] },
{ "sWidth": "110px", "aTargets": [ 7 ] },
{"sSortDataType": "dom-select", "aTargets": [ 1 ]},
{"sSortDataType": "dom-select", "aTargets": [ 2 ]},
{"sSortDataType": "dom-select", "aTargets": [ 4 ]},
{"sSortDataType": "dom-select", "aTargets": [ 5 ]},
{ "bVisible": false, "aTargets": [ 7 ] },
{ "bVisible": false, "aTargets": [ 8 ] },
{ "bVisible": true, "aTargets": [ 9 ] },
{ "bSearchable": true, "aTargets": [ 10 ] },
{ "bSearchable": true, "aTargets": [ 11 ] },
{ "bVisible": false, "aTargets": [ 11 ] }
],
[/code]
Cheers,
Niklas
It works well for all my column except one that has dates of format 2012-05-25 15:41:35. When entering '2', all columns are filtered away, but all should remain in the table.
This column is the right most one. Between this and the other visible columns to the left I have two hidden columns. Like this:
[col1 (visible)][col2 (visible)]......[col 8 (hidden)][col 9 (hidden)][col 10 - Date]
When making col 9 visible (using ColVis), then it works. Entering '2' makes all rows still being present in the table (all starts on 2012).
To verify that the problem has to do with ColVis and not the actual date-column I changed the column visibility like this:
[col1 (visible)][col2 (visible)]......[col 8 (hidden)][col 8 (hidden)][col 9 (visible)][col 10 - Date]
Now, trying to filter on col 9 shows the same symptoms. I.e., entering 'k' if many rows starts on 'k' filters those away and leaves the table empty.
Is this a known issue? Does anyone know how to fix this?
Just in case this can have any importance for the problem:
[code]"aoColumnDefs": [
{ "asSorting": [ "desc", "asc", "desc" ], "aTargets": [ 0 ] },
{ "sWidth": "55px", "aTargets": [ 0 ] },
{ "sWidth": "65px", "aTargets": [ 1 ] },
{ "sWidth": "140px", "aTargets": [ 2 ] },
{ "sWidth": "100px", "aTargets": [ 3 ] },
{ "sWidth": "100px", "aTargets": [ 4 ] },
{ "sWidth": "85px", "aTargets": [ 5 ] },
{ "sWidth": "140px", "aTargets": [ 6 ] },
{ "sWidth": "110px", "aTargets": [ 7 ] },
{"sSortDataType": "dom-select", "aTargets": [ 1 ]},
{"sSortDataType": "dom-select", "aTargets": [ 2 ]},
{"sSortDataType": "dom-select", "aTargets": [ 4 ]},
{"sSortDataType": "dom-select", "aTargets": [ 5 ]},
{ "bVisible": false, "aTargets": [ 7 ] },
{ "bVisible": false, "aTargets": [ 8 ] },
{ "bVisible": true, "aTargets": [ 9 ] },
{ "bSearchable": true, "aTargets": [ 10 ] },
{ "bSearchable": true, "aTargets": [ 11 ] },
{ "bVisible": false, "aTargets": [ 11 ] }
],
[/code]
Cheers,
Niklas
This discussion has been closed.
Replies
[code]$("tfoot input").off('keyup');
$("tfoot input").on('keyup', function (event) {
alert($("tfoot input").index(this));
var col_index = oTable.fnVisibleToColumnIndex(oTable.fnSettings(), $("tfoot input").index(this));
alert(col_index);
oTable.fnFilter( this.value, col_index, true);
} );[/code]
What's the correct way of using fnVisibleToColumnIndex?
[code]$("tfoot input").off('keyup');
$("tfoot input").on('keyup', function (event) {
alert($("tfoot input").index(this));
var col_index = oTable.fnVisibleToColumnIndex($("tfoot input").index(this));
alert(col_index);
oTable.fnFilter( this.value, col_index, true);
} );[/code]
The 'settings' object is admittedly a bit messy, but we are a bit stuck with it for the moment until a major API change (certainly won't happen before v2).
Allan