Filtering rows through the search bar based on the option selected in the dropdown menu.

Filtering rows through the search bar based on the option selected in the dropdown menu.

captainspicaptainspi Posts: 3Questions: 0Answers: 0
edited October 2013 in General
Hi there,

I love DataTables. It's a great plugin. I can't express my appreciation enough for how much it has helped me out! Thank you for the amazing work.

I have, however, run into a problem. Some of my rows have cells with dropdown menus with various options, therefore these can be changed dynamically. I would like to take the selected options into account when I type my query in the search bar to filter the data table.

Is this possible? I have managed to implement the Live Dom Sorting funcionality, but I am still at sixes about the other issue. I have noticed that if I sort the column first and then type my query in the search bar, it works like it should. However, I would rather not keep clicking on each column before typing in my next query.

Thank you for going through this!

Best wishes,
Omar Ansari

Replies

  • captainspicaptainspi Posts: 3Questions: 0Answers: 0
    Apparently I need to refresh the internal cache:

    http://datatables.net/forums/discussion/11143/filtersort-cache-updates-for-sorting-but-not-filtering/p1

    Could someone tell me how one would go about implementing that code? I tried to add it to the API ($.fn.dataTableExt.oApi.functionName) but that didn't work either. I would appreciate any support!

    Thanks.
  • captainspicaptainspi Posts: 3Questions: 0Answers: 0
    edited October 2013
    Right, so the issue definitely was the internal cache. You have to strategically update it upon initializing the table and whenever else you detect a user has inserted a new entry/edited an existing entry to ensure the internal cache reflects the content in your tables.

    Many thanks to Wintermute for creating the amazing function. I placed it in the datatables class in root/media/js/jquery.dataTables.js

    Hope this helps a fellow wanderer somewhere down the line.
This discussion has been closed.