base on one filtered result and apply another filter

base on one filtered result and apply another filter

miaomiao Posts: 1Questions: 0Answers: 0
edited November 2013 in General
hello,

what I am trying to do is such as run fnFilter() multiple times but each time based on previous results.

such as for table
[quote]
name | location
----------------
alan | ab
john | bc
joe | ab
[/quote]

to run fnFilter() twice

[code]
$('#example').dataTable().fnFilter(
"n",
0,
true,
false
);
[/code]
fist this filter on name column and will match the alan and john

[code]
$('#example').dataTable().fnFilter(
"a",
1,
true,
false
);
[/code]
then want to narrow down the result to match "a" in location column so I want it return

[quote]
name | location
---------------
alan | ab
[/quote]

but run fnFilter() in sequence only return last filter result, will be:
[quote]
name | location
-----------------
alan | ab
joe | ab
[/quote]
I feel it is so hard to find a solution, please give me some advice

In this example http://datatables.net/release-datatables/examples/api/regex.html
does show what I want that filter combine all patterns, but how to implement automatically,

I will need to search different pattern on different column and these are saved in JSON
for example {"filter":[ {"what":"pattern1","where":"column1","how":"regex match"},{"what":"pattern2","where":"column2","how":"invert regex"}]}
this filter will do regex match on column1 with pattern1, and do invert regex match on column2 with pattern2.

every time load page I will want to load JSON and apply the combined filters
This discussion has been closed.