Filtering - an exact match
Filtering - an exact match
Hey.
When filtering specific columns using a select - I don't want it to filter smartly.
If I filter by code for example, and I look for '1', I don't want it to find all the '1' as well as all of the '11'.
I wrote oSettings.aoPreSearchCols[ iColumn ].sSearch = '1'; oTable.fnDraw(); , and got '11' as well.
What can I do?
When filtering specific columns using a select - I don't want it to filter smartly.
If I filter by code for example, and I look for '1', I don't want it to find all the '1' as well as all of the '11'.
I wrote oSettings.aoPreSearchCols[ iColumn ].sSearch = '1'; oTable.fnDraw(); , and got '11' as well.
What can I do?
This discussion has been closed.
Replies
Thanks,
Vivek
oSettings.aoPreSearchCols[ iCol ].sSearch = '1';
Hence, I do:
oSettings.aoPreSearchCols[ iCol ].bRegex = false;
oSettings.aoPreSearchCols[ iCol ].bSmart= false;
I also tryed:
oSettings.aoPreSearchCols[ iCol ].bRegex = true;
oSettings.aoPreSearchCols[ iCol ].bSmart= false;
Both didn't work out.
Any ideas?
[code]
oSettings.aoPreSearchCols[ iCol ].sSearch = "^\\s*"+'1'+"\\s*$";
oSettings.aoPreSearchCols[ iCol ].bRegex = false;
oSettings.aoPreSearchCols[ iCol ].bSmart= false;
[/code]
let me know it works for you are not...
Worked like a charm - thanks.
[code]oTable.fnFilter("^"+some_string+"$", some_column_id, true);[/code]
As for chogger's question, I couldn't find documentation on oSettings anywhere on this site, in the end I found it from stackoverflow... Looks like this:
[code]
// after creating the table and getting the table object...
var oTable = $('#some_id').dataTable();
// ...you can use it to get a settings object...
var oSettings = oTable.fnSettings();
// ...then you can do things with the settings object
oSettings.aoPreSearchCols[ iCol ].sSearch = "^\\s*"+'1'+"\\s*$";
oSettings.aoPreSearchCols[ iCol ].bRegex = false;
oSettings.aoPreSearchCols[ iCol ].bSmart= false;
[/code]
I feel that this is possibly the biggest weakness in DataTables at the moment... :-(. oSettings was never intended (way back when I started DataTables) to be publicly documented (it is however fully documented in the code, if you look in the file), but it has become increasingly important that this and all the other internals of DataTables are fully documented. When 2.0 happens I plan to restructure DataTables to have it make a lot more sense from this point of view and full automatic documentation as well
Until then, its a case of looking at the code if you want to mess around with the settings object.
Having said that, generally you shouldn't need to - for example all that you've done above can be done with the publicly documented fnFilter API method.
Regards,
Allan