using $.fn.dataTableExt.afnFiltering.push to filter tables

using $.fn.dataTableExt.afnFiltering.push to filter tables

pjogpjog Posts: 9Questions: 0Answers: 0
edited July 2013 in General
I am using the above function to override my filter functionality as @allan has shown in http://live.datatables.net/etewoq/4/edit#source.
I have 1 table on my web page with another table that loads on the modal and I need to filter the table in the modal with date range.
How do I make sure this function applies to my table in the modal and not on the page.

In simple language if there are multiple tables in the page how do you make $.fn.dataTableExt.afnFiltering.push apply to the table you want ?

Replies

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    You need to add some logic to have it detect which table it is working with. Its a bit obscure, but you can use `settings.nTable.id` to get the ID of the table that the filter is looking at at any given time (where `settings` is the first argument passed into the function).

    Allan
  • pjogpjog Posts: 9Questions: 0Answers: 0
    Can you give me an example how to use [code] settings.nTable.id [/code]
  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    [code]
    $.fn.dataTableExt.afnFiltering.push(
    function( settings, aData, iDataIndex ) {
    if ( settings.nTable.id === 'example' ) {
    // filter example
    }
    else {
    // ...
    }
    }
    );
    [/code]
This discussion has been closed.