Remove custom filtering
Remove custom filtering
I have a page that uses Comet to switch between two panels that use DataTables. One of them has the custom filter shown below. When I switch from the panel that uses the custom filtering to the panel that does not, this filter is causing an exception.
So what is the best way to set things up so that I can easily add and remove this filter at need?
Thanks,
Donald
[code]
/* Custom filtering function which will filter data in column four between two values */
$.fn.dataTableExt.afnFiltering.push(
function (oSettings, aData, iDataIndex) {
var selectCode = document.getElementById('statusSelect').value;
return filterRow(selectCode, aData);
}
);
[/code]
So what is the best way to set things up so that I can easily add and remove this filter at need?
Thanks,
Donald
[code]
/* Custom filtering function which will filter data in column four between two values */
$.fn.dataTableExt.afnFiltering.push(
function (oSettings, aData, iDataIndex) {
var selectCode = document.getElementById('statusSelect').value;
return filterRow(selectCode, aData);
}
);
[/code]
This discussion has been closed.
Replies
Unfortunately this is probably one of the biggest weak points of DataTables as it currently dads as these filters are not instance based (i.e. they apply to all tables).
The work around is to check in your function if the table that is being operated on is the filter that you want to apply the file to. For example:
[code]
/* Custom filtering function which will filter data in column four between two values */
$.fn.dataTableExt.afnFiltering.push(
function (oSettings, aData, iDataIndex) {
if ( oSettings.nTable.id === "my_filtering_table" ) {
var selectCode = document.getElementById('statusSelect').value;
return filterRow(selectCode, aData);
}
else {
return true;
}
}
);
[/code]
Making these extensions optional on an instance basis will form part of the work that will go into v1.10.
Allan
Thank you for your help!
Donald