reset filter

reset filter

santiagozkysantiagozky Posts: 8Questions: 0Answers: 0
edited November 2009 in General
Hello,

I have implemented a small piece of code to allow the user search in a particular column. My problem is that if the user change the column and perform a second search the search is performed over the results of the previous search.

So if I do a search in the 3 column and get 50 results and then I search in the 1 column I will only be searching within t 50 results, not the entire data.

Here is the code:

[code]
//the div with the search input
var elDiv=$("#example_filter > input");
//I create a select that will be populated with the column names
var select = document.createElement( 'select' );
select.setAttribute("name","columna");
$(elDiv).before(select);
//I add the options to the select
var aoColumns = oTable.fnSettings().aoColumns;
for(var i=0;i

Replies

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

    I think the problem is that what is happening is:

    1. User selects a column to search on using the 'select' menu
    2. Enters search string and this is applied to that column
    3. User selects a different column using the 'select' menu
    4. The global search is cleared, but NOT the search on the individual column from before
    5. Enters search string into input box, and is now doing an 'AND' search between the value first entered for the first column, and the value entered for the second column!

    So the key step here is 4. What you need to do, rather than clearing the global filter, is clear the old column specific filter ( $oTable.fnFilter("", whatever_the_last_index_was); for example).

    Hope this helps,
    Allan
  • santiagozkysantiagozky Posts: 8Questions: 0Answers: 0
    great, I didn't know that I had to clear the search for every column. It worked fine.

    Thanks allan.
  • hoffmanchoffmanc Posts: 1Questions: 0Answers: 0
    Any way to remove filtering without triggering a redraw each time?
This discussion has been closed.