2 DataTables on a website - how to use a range-filter on the 1st only????

2 DataTables on a website - how to use a range-filter on the 1st only????

douglasdouglas Posts: 5Questions: 0Answers: 0
edited June 2010 in General
Hello everyone,

not sure if this is a "general" thing, but...

I got 2 Tables ( id's are "a" and "b", different amount of columns - 8 and 5), and I got 2 textfields to filter a date range. I want to filter the 8th column of table "a".

I am using $.fn.dataTableExt.afnFiltering.push(), but it's trying to do the range on the 2nd table ("b"). When I remove the 2nd Table, it works! How can I tell the push()-Function to use the 1st table ("a") but still keeping the 2nd table on the website?

Thanks in advance.

Douglas

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi Douglas,

    This is an unfortunate side effect of how the filtering plug-ins are applied to DataTables. The way around it is to check to see if the oSettings variable (first parameter in the function) matches the settings variable for the first table or not. If it does, then perform the filtering - if not, then return true (i.e. no filter).

    It's not a particularly elegant way of doing this I'll be the first to admit - I really hope in future to find a better way of doing it (when I get a chance to re-architecture DataTables...).

    Regards,
    Allan
  • douglasdouglas Posts: 5Questions: 0Answers: 0
    edited June 2010
    Hi Allan,

    thank you for the hint.

    I solved it by adding following line somewhere in the push() function:

    [code]if ( oSettings.sInstance == 'a' ) { ... } [/code]
This discussion has been closed.