Button Filter
Button Filter
Tiago_Nunes
Posts: 3Questions: 0Answers: 0
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
Thanks
This discussion has been closed.
Replies
Allan
$(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.
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