adding items to the afnFiltering array (or something alike), but just for one table.

adding items to the afnFiltering array (or something alike), but just for one table.

ycdtosaycdtosa Posts: 3Questions: 0Answers: 0
edited May 2013 in Plug-ins
Hi. I'm trying to get a custom row filter linked to a select for one table. The filter is somehow tricky and i went for a row filter via

[code]$.fn.dataTableExt.afnFiltering.push( ... )[/code]

The code was working fine, except that it is being applied by other unrelated tables. (opes!)

While preparing a testcase i did find one almost identical, related with a previous question.
http://live.datatables.net/oyinin/3/edit#javascript,html,live

So, that is the same that I'm doing, I'm pushing a filter function into the afnFiltering array.

The question is, Could i add the filtering function to the afnFiltering array for just one of the tables?

I can get away with it, somehow. For instance i can get the desired behavior just checking the id of the table http://live.datatables.net/oyinin/139/edit, but it feels sub-optimal :-)

...there sure is a better way to archieve this, that does not involve calling the filter at all for the other tables..

Thanks is advance.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Currently you need to perform a test in the filter to see if it is acting on the table that you want, very much as you are doing. It is indeed suboptimal, but its the only way of doing it with the DataTables API currently. This is something I'm going to be looking at addressing in future:
    http://datatables.net/development/roadmap

    Regards,
    Allan
  • ycdtosaycdtosa Posts: 3Questions: 0Answers: 0
    ok. thanks a lot for the (very) quick answer.

    i went with
    [code]
    $.fn.dataTableExt.afnFiltering.push (
    function( oSettings, aData, iDataIndex ) {
    if ( oSettings.sTableId !== 'table_i_want_to_filter' )
    //do not apply to other tables.
    return true;

    //filter code goes here...
    }
    );
    [/code]

    Nethertheless, thanks a lot for the dataTables.

    Greets
  • ycdtosaycdtosa Posts: 3Questions: 0Answers: 0
    edited May 2013
    humm.. reading your roadmap.. I just have to say that i find the Hungarian notation very helpfull to undestand the nature of the data.
    For instance, the afnFiltering "array of functions" nature is very well depicted in its name.

    I guess some people might find it ugly, but it sure is useful.

    just me saying!

    Best Regards
This discussion has been closed.