Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Ansgar on Jul 20, 2008 22:46
open dhtmlx forum
DHTMLXGrid - dropdown filter using "wildcards" ?

Hi there,
is it possible to make a dropdown filter box in DHTMLXGrid to search with a kind of "wildcard" like "*" or "%" in the cell?
I mean like this:

dropdown filter with items "CAR", "BUS", "BIKE" ....

By selecting one of those filter options, the cells would be filtered with a kind of "wildcard", like for example selecting "CAR" would also filter the cell containing "MYCAR" or "CAR99" or "MYCAR99"

Thanks for your support!

Answer posted by Support on Jul 21, 2008 02:33
Built in #select_filter can't work in such mode , but you can create custom control with such functionality

<select onchange="mygrid.filterBy(1,this.value);">
    <option value="CAR">CAR</option>
    <option value="BUS">BUS</option>
    <option value="BIKE">BIKE</option>
</select>

where 1 - index of column to which filter will be applied
Answer posted by Ansgar on Jul 21, 2008 04:35
Hi,
thanks for your good and quick response.
This is working fine so far.
But is it also possible to "combine" two of those filters, which means that I select one item in dropdown filter column A and after that I select another item in dropdown filter column B. The filter of column B should only run on the before selected items of the filter in column A. Is this possible?



Answer posted by Support on Jul 21, 2008 06:49
Yes, it possible.
Code will be siimilar to next

<select id="selectA" onchange="filter();">
....
<select id="selectB" onchange="filter();">
....

function filter(){
    mygrid.filterBy(1,document.getElementById('selectA'));
    mygrid.filterBy(2,document.getElementById('selectB'),true);
}

The true as 3rd parameter of filterBy says that command must filter agains previously filtered set instead of filtering against original set.