Replacing DT input filtering but keep the element in sDom
Replacing DT input filtering but keep the element in sDom
Greetings.
Is it possible to replace the default filtering process but keep the original sDom filtering element? I don't want to build a copy of the element but I do want to replace the default filtering with my own.
My scenario is that I have many similar tables on many pages with 5-500+ rows and ~5 cols. The last col always contains clickable icons that perform an action with the row data. I need custom filtering to ignore the last column and to ignore element classes as rows can contain spans with classes I don't want to be searched.
Is it possible to replace the default filtering process but keep the original sDom filtering element? I don't want to build a copy of the element but I do want to replace the default filtering with my own.
My scenario is that I have many similar tables on many pages with 5-500+ rows and ~5 cols. The last col always contains clickable icons that perform an action with the row data. I need custom filtering to ignore the last column and to ignore element classes as rows can contain spans with classes I don't want to be searched.
This discussion has been closed.
Replies
Visual Event is quite useful for these things: http://sprymedia.co.uk/article/Visual+Event+2
Allan
Use bSearchable .
> and to ignore element classes as rows can contain spans with classes I don't want to be searched.
As in colspan? colspan / rowspan is not supported in the DataTables tbody.
Allan
But then I would need to know the amount of columns per table, wouldn't I? The amount varies quite a bit and I would love to keep the configuration to one config object and one custom filter that fits all tables.
[quote]Yes - you need to unbind the 'keyup' event listener that DataTables attaches to the input element and then bind your own to it to perform the filtering.[/quote]
I was afraid I would have to do something like this - maby I'll just leave the double filtering in place because it's easier...
As for the classes I meant, sorry for not being clear. If I have this kind of a row (edited):
[code]
My awesome pony 33392
[/code]
That particular row is shown if filtering with "202", "compilation", "awesome", "icon", "publish" or "Julk" but I need it to match only "My" "awesome" "pony" and "33392". I do this with a custom filter and it works well enough for now, I was just wanting to remove the original filtering as being redundant for me and if it would make the filtering a little faster that would be great. It's not slow but I want it to be as fast as possible :).
You can use aoColumnDefs and aTargets to target a column of a specific class. So for example `` could be used with `aTargets: ['no-search']` .
> That particular row is shown if filtering with "202", "compilation", "awesome", "icon", "publish" or "Julk" but I need it to match only "My" "awesome" "pony" and "33392".
That's a bug in DataTables 1.9.4 :-(. It absolutely should be removing the HTML from the filter by default - it does in 1.9.3- and it will in 1.10+... This is the fix for that issue: https://github.com/DataTables/DataTables/commit/065c2cc66b872c6964b7d31f12941f23e7f1f171
You could put that into your local DataTables and it should just work.
Allan