$.fn.dataTableExt.afnFiltering.push not work with dd-mm-yyyy

$.fn.dataTableExt.afnFiltering.push not work with dd-mm-yyyy

theppiwattheppiwat Posts: 5Questions: 1Answers: 0

i try to use $.fn.dataTableExt.afnFiltering.push for daterangefilter it's work fine with day to day but when pick month like
12/7/2019 - 1/8/2019 not work with month
12/7/2017 - 1/8/2019 not work with year
12/7/2019 - 31/7/2019 work fine only with day

Answers

  • colincolin Posts: 5,619Questions: 0Answers: 981

    Hi @theppiwat ,

    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

  • theppiwattheppiwat Posts: 5Questions: 1Answers: 0

    http://live.datatables.net/burokodi/2/edit here is my test case.so sorry this's first time

  • colincolin Posts: 5,619Questions: 0Answers: 981

    Hi @theppiwat ,

    There's several errors in that script, giving errors in the console.

    1. For example, you're splitting min and max before checking if they're empty strings, so you need to move that empty test higher up in the function.
    2. you're referencing createdAt[4], when it only splits into two
    3. comparing createdAt2 is only comparing a string, it has no knowledge of dates

    I would suggest using Moment.js, as it's excellent for all time/date based operations.

    Cheers,

    Colin

  • theppiwattheppiwat Posts: 5Questions: 1Answers: 0

    Thank for you anwser , Now , i found another problem it's my date column can't sort (dd-mm-yyy format) then i tried to use https://datatables.net/blog/2014-12-18 but get this ERROR TypeError: $.fn.dataTable.moment is not a function

  • colincolin Posts: 5,619Questions: 0Answers: 981

    You need to include the source for MomentJS, see the links here.

  • theppiwattheppiwat Posts: 5Questions: 1Answers: 0

    i already include MomemntJs(angular-cli.json) but still get ERROR and i try to include //cdn.datatables.net/plug-ins/1.10.19/sorting/datetime-moment.js and
    //cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.4/moment.min.js in index page too then get same ERROR i'm so confuse what i what i doing wrong. Thank you so much for your anwser

  • colincolin Posts: 5,619Questions: 0Answers: 981

    Hi @theppiwat ,

    Would you be able to update your test case to demonstrate this issue, please?

    Cheers,

    Colin

  • theppiwattheppiwat Posts: 5Questions: 1Answers: 0

    Hi @colin i just solved my problem. I need to order moment.js before datatable then work fine. Thank you so much for your https://datatables.net/blog/2014-12-18#Operation link

Sign In or Register to comment.