fnfilter not refreshing the table
fnfilter not refreshing the table
I am using fnfilter and I do not see that the table is getting refreshed. I added the fndraw at the end too but no luck.
I viewed the text and its correct
I viewed the value of tabletofilter and selector is the name of my datatable
var obj, tableToFilter, colToFilter;
$('#btnFilter').click(function () {
tblFilter(filterText, oTable, 0);
});
function tblFilter(obj, tableToFilter, colToFilter) {
var val = $(obj).val();
if (val == "All") {
tableToFilter.fnFilter("(.*)", colToFilter, false);
tableToFilter.fnDraw();
} else {
tableToFilter.fnFilter("^" + val + "*" , colToFilter, false);
}
}
Am I missing something causing it not to refresh?
/* Initialize table and make first column non-sortable*/
oTable = $('#salespeople').dataTable({
"bProcessing": true,
"bJQueryUI": true,
"bServerSide": true,
"bLengthChange": true,
"bPaginate": false,
"bFilter": false,
"sAjaxSource": '/Manage/GetSales',
"aoColumns": [
null,
null,
null,
null,
null,
{ "bSortable": false, "bSearchable": false,
"fnRender": function (oObj) {
return '';
}
}
]
});
I viewed the text and its correct
I viewed the value of tabletofilter and selector is the name of my datatable
var obj, tableToFilter, colToFilter;
$('#btnFilter').click(function () {
tblFilter(filterText, oTable, 0);
});
function tblFilter(obj, tableToFilter, colToFilter) {
var val = $(obj).val();
if (val == "All") {
tableToFilter.fnFilter("(.*)", colToFilter, false);
tableToFilter.fnDraw();
} else {
tableToFilter.fnFilter("^" + val + "*" , colToFilter, false);
}
}
Am I missing something causing it not to refresh?
/* Initialize table and make first column non-sortable*/
oTable = $('#salespeople').dataTable({
"bProcessing": true,
"bJQueryUI": true,
"bServerSide": true,
"bLengthChange": true,
"bPaginate": false,
"bFilter": false,
"sAjaxSource": '/Manage/GetSales',
"aoColumns": [
null,
null,
null,
null,
null,
{ "bSortable": false, "bSearchable": false,
"fnRender": function (oObj) {
return '';
}
}
]
});
This discussion has been closed.
Replies
I see it stepping through the method all the values are right.
The columns start with 0 and I tried with regular expr and without.
Thanks again
What does fnfilter do?
Basically I could just call a new method to query with the filter and rebind the grid.
calling fnFilter() with bServerSide true will do nothing on it's own, just request for the server script to filter your data. if your server side script doesn't perform the filtering, you'll see no change in the data.