Wierd behavior with fnFilter?

Wierd behavior with fnFilter?

bulldogcreativebulldogcreative Posts: 2Questions: 0Answers: 0
edited June 2010 in General
Hi all,

I haven't had that much a problem with DataTables -- it's extremely useful, but I've come across this problem that I can't solve and I'm wondering if anyone has had similar experience. On this page:

http://www.njrati.org/research-projects-test-3/

We have a page with basically a table of data. I have a search area at the top that allows you to select which column to search in, and a text box that lets you type what you're searching for. The fnFilter() call is made on keyup on the text box.

My problem is that after some searches, and changing of columns, it bugs -- doesn't show anything, and am unable to get the original, unfiltered table back, even though there's nothing filtering it. I've been able to consistently reproduce it, but haven't been able to reproduce fixing it (it seems to bring the data back after clicking on different column options a few times and making sure the text box is empty).

To reproduce it, type "geo" into the search box (it filters). Now select Areas of Focus (radio); still filtered. Now select an irrelevant field, such as Principal Investigator; no results are displayed (of course, there is no geo in this column), but after switching to all, the results won't come back. Even removing the query from the text box won't make it come back. After some changing and messing with it, the data will re-appear.

I've checked everything... I'm positive it's not a problem in my code, but I could be wrong =) Can anyone help?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi bulldogcreative,

    Your page is giving a 404 error unfortunately. However, at a guess, are you using column filtering ( fnFilter(search, col) )? If so, then you might not be clearing the filter that is applied to a specific column - which would probably cause this kind of behaviour. Checking the values in $.fn.dataTableSettings[0].aoPreSearchCols (an array of objects, with one for each column) using Firebug will tell you what the current columns search strings are.

    There is a clear all filtering plug-in which may help: http://datatables.net/plug-ins/api#fnFilterClear - which is the hammer approach - or clearing your filter from the previous column search (assuming my guess is right).

    Regards,
    Allan
  • bulldogcreativebulldogcreative Posts: 2Questions: 0Answers: 0
    Hey Allan,

    Thanks for the help... that was it! After accounting for that in my code, all seems to be well. My implementation will be visible on the web by tomorrow (Friday) afternoon at: http://www.njrati.org/research/research-projects/ if you're curious.
This discussion has been closed.