Datatables daterange filter not working with column().index()
Datatables daterange filter not working with column().index()
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
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
Hi Colin,
Thanks for your reply
I created a JS fiddle, hope this makes this more clear: https://jsfiddle.net/9qz4mf2h/
Thanks!
Hi @rvdb.holder ,
You need to use
var iStartDateCol = $('table.dataTable')
rather thanvar iStartDateCol = $('table')
. When the date picker is visible it usestable
tags as well, so$('table')
is picking them up. Likewise with theiEndDateCol
Cheers,
Colin