Datatable filter search on two columns ?

Datatable filter search on two columns ?

motguptamotgupta Posts: 19Questions: 5Answers: 0
edited June 2014 in Free community support

I have 4 columns in datatable out of which 2 are searchable(i.e bSearchable is true). I want to filter the datatable on page load where filter
value is searched among two columns. I tried below but it returns the result when value(testVal) exists in both column i.e column 1 and column 2

 testDataTable.fnFilter( "testVal", 1, true);
 testDataTable.fnFilter( "testVal", 2, true);

What i am looking for is datatable return result when value i.e testVal exist in either of column 1 or column 2. Is there a function
exist in datatable for this ? I could not find it on http://legacy.datatables.net/ref

Answers

  • allanallan Posts: 61,970Questions: 1Answers: 10,160 Site admin

    DataTables' column filtering is an AND operation - there is no option for OR filtering in the built in filtering. For that you would need a custom filtering plug-in: http://datatables.net/examples/plug-ins/range_filtering.html

    Alternatively, if you are only using 4 columns and two aren't filterable, you could just use the global filter?

    Allan

This discussion has been closed.