Custom search/filter function.

Custom search/filter function.

LeprosyLeprosy Posts: 7Questions: 1Answers: 0
edited September 2015 in Free community support

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

  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67

    You also can try my yadcf and its filter_type: 'custom_func' or multi_select_custom_func , see first column on the showcase scroll down for code snippet

  • LeprosyLeprosy Posts: 7Questions: 1Answers: 0

    I'll check it out...but IMHO I think it's a basic feature that must be present on the core library.

  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67
    edited September 2015

    it is in the core, eventually under the hood yadcf use the api of datatables.

  • LeprosyLeprosy Posts: 7Questions: 1Answers: 0

    Can you show me a link to a documentation of it?

  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67

    Its all in the js file

  • LeprosyLeprosy Posts: 7Questions: 1Answers: 0

    I mean, the core methods to add custom filtering in DataTables.

  • LeprosyLeprosy Posts: 7Questions: 1Answers: 0

    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.

  • LeprosyLeprosy Posts: 7Questions: 1Answers: 0

    Also, where can I found an example of filters in the footer of the table?

  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67
    edited September 2015

    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)

  • LeprosyLeprosy Posts: 7Questions: 1Answers: 0

    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).

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    @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.

  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67

    @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 :)

This discussion has been closed.