fnfilter for each column ?

fnfilter for each column ?

bzbzbzbz Posts: 6Questions: 0Answers: 0
edited November 2013 in General
HI.
i would like to use a filter for each column with checkbox.
For just one column it's ok but i don't know how use the script to add the same filter for others.
Thanks.

http://fiddle.jshell.net/haTd3/3/

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Not quite sure I understand I'm afraid. You are already using fnFilter to limit the column filter to a single column (the first, `0` , column in your example). Would you not just do the same again with the other column indexes?

    Allan
  • bzbzbzbz Posts: 6Questions: 0Answers: 0
    edited November 2013
    Hi allan.
    Yes i just want to do the same again with each columns indexes.
    $('#example').dataTable().fnFilter(filter, 0, regexFilter, smartFilter);
    $('#example').dataTable().fnFilter(filter, 1, regexFilter, smartFilter);
    $('#example').dataTable().fnFilter(filter, 2, regexFilter, smartFilter);
    .....
    it may be simple, but I'm not familiar with the javascript language. I tested things without success...

    Thanks.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    You are passing in the same value of `filter` (etc) into the search for each column. Is that what you want to do?
  • bzbzbzbz Posts: 6Questions: 0Answers: 0
    no i don't want passing same value. I want a filter by column, but i don't know where write it.
    Maybe you're understand with this ie (it not work...):

    http://fiddle.jshell.net/haTd3/5/
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I'm afraid I don't really understand. You've got some code which works for filtering one column:

    [code]

    $(':checkbox[name="rendering_filter"]').click(function() {
    var filter = '',
    regexFilter = true,
    smartFilter = false;

    filter = $('[name="' + this.name + '"]:checked').map(function () {
    return this.value;
    }).toArray().join('|');

    $('#example').dataTable().fnFilter(filter, 0, regexFilter, smartFilter);
    });
    [/code]

    Why not duplicate it for the other columns?

    Better yet would be to put it in a function and call it, passing in the column index you want to filter on, so you don't have large amounts of duplicate code.
This discussion has been closed.