Custom search/filter function.
Custom search/filter function.
Is there a way to use filter()
to filter the data in the current table instead of creating another instance? I need to filter a column of an specific DataTable(with other present on the same page) with a custom function(for example, all rows in which the number of that column are > 0). The filter()
method doesn't update the rows of the current table and the column.search()
doesn't accept a custom filter function. Using $.fn.dataTable.ext.search
seems to be cumbersome, it seems to add a search to ALL the other tables. Can something like this be achieved?
Thanks in advance.
Answers
You also can try my yadcf and its
filter_type: 'custom_func'
ormulti_select_custom_func
, see first column on the showcase scroll down for code snippetI'll check it out...but IMHO I think it's a basic feature that must be present on the core library.
it is in the core, eventually under the hood yadcf use the api of datatables.
Can you show me a link to a documentation of it?
Its all in the js file
I mean, the core methods to add custom filtering in DataTables.
I was unable to run your plugin using the new API(I'm using the last version of DataTables), but it worked with the old API calls...weird. Also, the API of your library is not able to be used with multiple tables, iterating with a jQuery set. Also, there is an issue when putting filters with tables that have columns hidden by default.
Also, where can I found an example of filters in the footer of the table?
You can read about the filter positions in the docs and see showcase example here,
Regarding your issue with the selcector I guess its related to this open issue planning to fix it one day (lack of time :| ),
About the new api and stuff, the
yadcf.init
will accpet only the object returned by the Capital D constructor of the datatables while on the lower case constructor you can call the.yadcf
function... (lowercase datatables construcot return a jQuery object)How about the filters on hidden columns? I have a table that has one or more data-visible attributes in the headers and for those columms, the filters are not being rendered (If I hide the column after the initialization of the yadcf plugin, the filter hides and show with the column in the appropiate fashion, though).
@leprosy I can vouch for the DT YADCF plugin.
I had some issues with the column filters that were provided in the DT Examples, Daniel showed me YADCF, and it works perfectly. I have yet to run into an issue with it, atleast an issue I couldnt solve by reading some of the docs.
@Leprosy , you can place your filters outsude the table ( using the filter_container_id ) so they wont be affected of the column visibilty , just like the third column at the showcase.
Thanks @jLinux :)