fnFilter & table display?

fnFilter & table display?

jfb1234jfb1234 Posts: 10Questions: 0Answers: 0
edited April 2012 in General
I have a web page that has two tabs with a datatable in each tab and a form for data entry. Focus is on the first tab and depending on what is entered in the form the first table or both tables could be updated. The following snippet shows my filter.
[code]$('#namesTable').dataTable().fnFilter($('#phoneNumberEast').val());
if (oNamesTable.fnPagingInfo().iFilteredTotal != 0){
// Have a match
$('input#phoneNumberEast').val('');
$('#phoneNumberEast').submit();
$('#tagNumberEast').focus();
}else {
// No match display lastname,firstname boxes and update names table
$('#firstLast').css('display', 'block');
// some more stuff[/code]

After this code runs the names table shows the results of the filter. The search is only to determine if one or both of the tables needs to be updated and I would like the display of the names table not to reflect the results of the filter. Is there a way to search in the background and not effect the display of the table?

Thanks, Jim

Replies

  • allanallan Posts: 63,936Questions: 1Answers: 10,539 Site admin
    Hi Jim,

    Two options off the top of my head:

    1. Use fnFilter with the second parameter given as false to stop the redraw of the table and then clear the filter on the next line (otherwise the filter would be applied on the next draw).

    2. Use fnGetData (or the underscore API method) to get the data from the table, loop through it and check for your string using indexOf or similar.

    Allan
  • jfb1234jfb1234 Posts: 10Questions: 0Answers: 0
    Allan,

    I had tried using fnFilter with the false parameter, but did not know to clear the filter. Once I used your suggestion about clearing the filter it worked just like I wanted.

    Thanks much.

    Regards, Jim
This discussion has been closed.