Why isn't the datatables filter() method not filtering out date ranges?

Why isn't the datatables filter() method not filtering out date ranges?

dt_userdt_user Posts: 51Questions: 16Answers: 0

Good night, I want to create a date range filter using the datatables filter function. But it isn't affecting or changing the table.
I tried using $.fn.dataTable.ext.search but that did not work for me.
Here is a link to my code: http://live.datatables.net/fahofoho/3/edit.
Please let me know where I am going wrong.
Thank you.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,160Questions: 26Answers: 4,921

    Your example is using filter() which does not filter the table but provides a result set that can be used in Javascript. From the filter() docs:

    This method should not be confused with search() which is used to search for records in the DataTable - i.e. the filter method does not change the rows that are displayed in the DataTable.

    I tried using $.fn.dataTable.ext.search but that did not work for me.

    Do you have an example we can look at?

    Bindrid has an example date range search plugin in this [thread]. See if it helps.

    Kevin

  • dt_userdt_user Posts: 51Questions: 16Answers: 0

    Thank you for replying but there isn't a link to Bindrid's thread.

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Hi @dt_user ,

    This example here shows an age range - you could use that as a template. You could then use Moment.js to do the comparisons.

    Cheers,

    Colin

  • kthorngrenkthorngren Posts: 21,160Questions: 26Answers: 4,921
    edited September 2019 Answer ✓

    Thank you for replying but there isn't a link to Bindrid's thread.

    Sorry, here you go:

    https://datatables.net/forums/discussion/39894/date-range-filter#latest

    Must be the weekend :-)

    This example here shows an age range

    I'm guessing Colin meant this example.

    Kevin

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Thanks Kevin, must be the weekend ;)

  • dt_userdt_user Posts: 51Questions: 16Answers: 0

    Thank you both.

This discussion has been closed.