Datatables daterange filter not working with column().index()

Datatables daterange filter not working with column().index()

rvdb.holderrvdb.holder Posts: 2Questions: 1Answers: 0

Hi guys,

I'm using the daterange filter on my Datatables: https://datatables.net/plug-ins/filtering/row-based/range_dates

This works perfectly when the variables are set to numbers like in the original JS plugin.

But when I'm changing the 'var iStartDateCol' or 'var iEndDateCol' numbers to the selector $('table').DataTable().column('.filter-start-date').index() i get a Cannot set property '_DT_CellIndex' of undefined error when selecting a new date.

Am I using the wrong type of selector or am I doing something different wrong?

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @rvdb.holder ,

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • rvdb.holderrvdb.holder Posts: 2Questions: 1Answers: 0

    Hi Colin,

    Thanks for your reply :)

    I created a JS fiddle, hope this makes this more clear: https://jsfiddle.net/9qz4mf2h/

    Thanks!

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @rvdb.holder ,

    You need to use var iStartDateCol = $('table.dataTable') rather than var iStartDateCol = $('table'). When the date picker is visible it uses table tags as well, so $('table') is picking them up. Likewise with the iEndDateCol

    Cheers,

    Colin

This discussion has been closed.