How can I determine if a match was found using fnFilter
How can I determine if a match was found using fnFilter
I've been using this great plugin for a couple of days now with much success, but have now run into something I can't figure out. I need to make a decision based on whether or not a match was found in a table. I don't need to know what the results are, just if there was a match.
Thanks, Jim
Thanks, Jim
This discussion has been closed.
Replies
Allan
iFilteredTotal does what I need.
Thanks, Jim
Just for info purposes. After a little testing I found that I don't need to use fnDrawCallback. The following code works without it.
[code]/* Callback to submit a validated addItemForm */
function addItemFormGood() {
var optionsAdd = {
target: '#msgArea',
clearForm: 'true',
success: addItemFocus
};
$('#namesTable').dataTable().fnFilter($('#phoneNumberEast').val());
if (oNamesTable.fnPagingInfo().iFilteredTotal == 0){
alert('no match');
} else {
alert('match');
}
return false;} [/code]
Regards, JIm
One thing to note for yourself or anyone else who finds this in future, if using server-side processing fnFilter() is async - so this probably wouldn't work, you'd need to use a callback function, since the following logic would run before the new data has been loaded.
Perfect for client-side processing though!
Allan