Developing a generic column-filtering plugin --- can I keep/add state to datatables settings?
Developing a generic column-filtering plugin --- can I keep/add state to datatables settings?
The examples I've seen of column filtering using a search plugins usually use some hard-wired UI to determine filtering conditions for a column --- like this one. I want to do this in a number of times, so I would like to automate creating the filtering input widget as well.
First of all --- does this exist already? No reason to write my own if it is out there.
Second: Ideally I would implement this by adding a column option. Is it possible to extend the options available? If so how do you do that, and how do you access the option values?
If not, or if it would be a ton of code to do so, I could instead create an API extension that looks something like column().addFilter( filtertype ). Now I need somewhere to store the filtertype information, and associate it with the column. Again, is there a way I can (or should) attach it to the Api object itself, or should I manage my own storage? And if managing my own storage, what should I use as an identifier for the column, that will be safe to use with potentially multiple tables, etc.?
Sorry if the question is not clear --- I'm trying to get my head around this stuff.
(And if I do actually write the plugin, I will of course post it here...)
This question has an accepted answers - jump to answer
Answers
YADCF is a fine plug-in for DataTables that adds various filtering options. It isn't written by myself, but the author is active on these forums .
Yes. Simply add the options that you want in the configuration object (you don't need to define them anywhere - DataTables doesn't strip any options that it doesn't know about out), then use
init()
to get the initialisation object. This is how my own plug-ins such as RowReorder etc work (example code).Allan
YADCF looks awsome! I will definitely start there. (Is there a reason it isn't on the list of plugins on this site?)
Yes - it is third party and I can't offer support for it. Having said that, I do need to find a way of advertising excellent plug-ins like YADCF better on this site!
Allan