Adding Date Range filter plugin in specific Datatable

Adding Date Range filter plugin in specific Datatable

glen2mampilglen2mampil Posts: 3Questions: 1Answers: 0

Hi Good morning,

I would like to add a date range filter plugin (https://datatables.net/plug-ins/filtering/row-based/range_dates) but my problem is. I have 3 different Datatable in a single page. (each table is place in the Tab).

Any Help guys? Thank you.

This question has an accepted answers - jump to answer

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    can you see what table is in the oSettings? for the other tables, just return true all of the time.

  • glen2mampilglen2mampil Posts: 3Questions: 1Answers: 0

    Hi @bindrid Thanks for the reply.

    I don't know where to find oSettings or how to access it.

    Here is my overview of my code:
    HTML markup

    JS / Jquery:

    My Problem was: I want to filter those column using Date Range (filtering the 1 column by Date from and Date To).

    I am using this plugin:

    But this plugin is working on the table1 (first table only) and when I apply some filter on the other 2 remaining table. It shows no available data (filter applied)

    I guess I messing up to the plugin.

  • allanallan Posts: 61,667Questions: 1Answers: 10,096 Site admin
    Answer ✓

    As you have seen, the filtering functions are shared between all DataTables. If you want to limit it to a specific table you could do something like:

    $.fn.dataTable.ext.search.push( function ( settings, data, dataIndex ) {
      if ( settings.nTable.id !== 'tableToSearch' ) {
        return true;
      }
    
      // Carry on with conditional logic.
    } );
    

    Allan

  • glen2mampilglen2mampil Posts: 3Questions: 1Answers: 0

    Hi @allan , Thank for you help.That code is what I am need.

This discussion has been closed.