Button Filter

Button Filter

Tiago_NunesTiago_Nunes Posts: 3Questions: 0Answers: 0
edited December 2011 in General
Hi, how can i make a filter with button? Because i have a very large database, so i cant put bfilter in every collumn, it would crash. So what i really like to do is something like this(http://www.datatables.net/examples/plug-ins/range_filtering.html), but with a button.

Thanks

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    I've put together a little example of how this can be done as this crops up on a reasonably regular basis: http://live.datatables.net/ejohek/edit

    Allan
  • Tiago_NunesTiago_Nunes Posts: 3Questions: 0Answers: 0
    Tks Allan your help was very usefull.
  • Tiago_NunesTiago_Nunes Posts: 3Questions: 0Answers: 0
    edited December 2011
    If i add more filter like this:

    $(document).ready(function() {
    var oTable = $('#tablecontent').dataTable();
    $('#tablecontent_filter input').unbind('keyup');
    $('Filter').appendTo('#tablecontent_filter').click( function () {
    oTable.fnFilter( $('#email').val() );
    oTable.fnFilter( $('#country').val() );
    oTable.fnFilter( $('#name').val() );
    } );
    } );

    and when call my function, i get 3 calls to my method search, one for each oTable.fnFilter.

    $(function(){
    oTable = $('#tablecontent').dataTable( {
    "bProcessing": false,
    "bServerSide": true,
    "sAjaxSource": url_site+"index.php?page=users&task=search&format=ajax",
    .
    .
    .
    .
    "sInfoFiltered": dtInfoFiltered,
    "sSearch": dtSearch,
    "oPaginate": {
    "sFirst": dtFirst,
    "sPrevious": dtPrevious,
    "sNext": dtNext,
    "sLast": dtLast
    }
    }
    } );
    });

    I would like to filter all the same time. Dont undestand why its calling 3, 4 times depending on the number of filters.
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    [code]
    oTable.fnFilter( $('#email').val() );
    oTable.fnFilter( $('#country').val() );
    oTable.fnFilter( $('#name').val() );
    [/code]

    You are setting the filter first to email value, then replacing it with the country value, then replacing that to end up finally with the name value. I presume you want to do column filtering - in which case you need to pass another parameter to fnFilter: http://datatables.net/api#fnFilter .

    Allan
This discussion has been closed.