fnFilter issue after making column invisible
fnFilter issue after making column invisible
I have a dropdown with options that allow the user to filter a specific column based on the value in the dropdown. An example is one where the options are All, Active, and Inactive. The filtering works great, even after reordering the column. The problem happens when the user hides the column that the sorting is being applied to. The first time the filter is applied after the specific column is hidden, everything works properly, but subsequent filtering attempts seem to only filter based on the data that was visible after that first filter. Example: The active column is hidden while all rows are present. The users selected "Active" from the dropdown, and only the rows who's active column has the value of active appear (despite that column being hidden). The user then chooses to "Inactive" from the dropdown and nothing is visible. The user then chooses "All" from the dropdown and on the active rows are visible. If the user then makes the active column visible, none of the filters work. I am using the ColReorder plugin for column reordering. The sDom is 'lrtip'. The filtering code is as follows:
[code]
var target = jQuery(event.target);
var columnOrder = this.toolView.dataGrid.colOrder.concat();
var index = jQuery.inArray('Active', columnOrder);
switch(target.val()){
case '':
this.toolView.dataGrid.dataTable.fnFilter('', index);
break;
case 'inactive':
this.toolView.dataGrid.dataTable.fnFilter('Inactive', index);
break;
case 'active':
this.toolView.dataGrid.dataTable.fnFilter('^Active', index, true);
break;
}
[/code]
Where the target is the dropdown and the columnOrder is an array of the column names that are being stored. At any given point during this process, I can do a getData on a cell in the column of index "index" and get either "Active" or "Inactive" which are the possible values for the Active column.
If I do a global filter, as opposed to a column specific filter, everything works properly. The only issue is that if another column contains the words active or inactive, then the associated row will show up, and I don't want that. It also prevents '^Active' from working unless the cell in the first column of that row has the value of Active.
[code]
var target = jQuery(event.target);
var columnOrder = this.toolView.dataGrid.colOrder.concat();
var index = jQuery.inArray('Active', columnOrder);
switch(target.val()){
case '':
this.toolView.dataGrid.dataTable.fnFilter('', index);
break;
case 'inactive':
this.toolView.dataGrid.dataTable.fnFilter('Inactive', index);
break;
case 'active':
this.toolView.dataGrid.dataTable.fnFilter('^Active', index, true);
break;
}
[/code]
Where the target is the dropdown and the columnOrder is an array of the column names that are being stored. At any given point during this process, I can do a getData on a cell in the column of index "index" and get either "Active" or "Inactive" which are the possible values for the Active column.
If I do a global filter, as opposed to a column specific filter, everything works properly. The only issue is that if another column contains the words active or inactive, then the associated row will show up, and I don't want that. It also prevents '^Active' from working unless the cell in the first column of that row has the value of Active.
This discussion has been closed.