Filtering date using Datepicker

Filtering date using Datepicker

motoradkmotoradk Posts: 2Questions: 1Answers: 0

Hello Everyone,
I have one problem with my Datatables. I want filter my datatable by date using Datepicker. I know that there is a "date-range" (columnFilter) but I want to single field of Datepicker, not "from" and "to". Any sugestions?

Answers

  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67

    If its for column filterting you can use my yadcf and its filter_type: "date" option , see third column on the showcase see code snippet at the bottom , yadcf support 'jquery-ui', 'bootstrap-datetimepicker' date pickers read docs

  • glendersonglenderson Posts: 231Questions: 11Answers: 29

    You should be able to format the datePicker into the same format that your column data is in.

    To make it the most sortable without having to define the sorttype, that would be "yyyy-mm-dd"

    For datepicker, that's a format of "yy-mm-dd". You need to format your date in dataTables in the same manner, it's just a string search.

    Please note, I'm assuming you really mean search when you say filter.

    Upon select of datePicker, you should be able to fire the dataDatables search method().

    $(yourdatepicker).datePicker({
    dateFormat: "yy-mm-dd" , 
    onSelect: function() {
    var table = $(#yourtable).DataTable();
    table.search( $(this).val() ).draw();}
    })
    
  • motoradkmotoradk Posts: 2Questions: 1Answers: 0

    yadcf works perfect! Thanks Guys for help, cheers !

This discussion has been closed.