Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Pravu Mishra on Jul 23, 2009 04:18
open dhtmlx forum
Single search box for text and combo columns in grid

Hi,

My grid contains many text fields and two dropdown(combo) fields. My screen has a single search field out side the grid for all the fields. I have used the same way of search shown in the example Filtering in Paging mode.

Following is my code that creates a search box.

<fieldset width=100%>
    <legend>Search</legend>
     Column Name
    <select id='a10'>
     <option value='1'>Course Code</option><option value='2'>Course</option><option value='3'>Faculty</option><option value='4'>Degree</option>
    </select>
    Value Like
    <input type="text" name="a12" value="" id="a12">
    <input type="button" name="a11" value="Search" id="a11" onclick='mygrid.filterBy(document.getElementById("a10").value,document.getElementById("a12").value);'>
   </fieldset>

Now I am getting the problem mentioned below.

search is working ok for all the other fields other than combo fields. For combo fields if the value of hidden field(ID) is entered then it searchs and displayes the found rows. If you enter the value that is getting displayed then it does not show any row. It means the search happens for the hidden fields in case of combo .

But I need to search according to the visible values in combo.

Can any body help me.

Thanks and Regard,

Pravu Mishra.

Answer posted by dhxSupport on Jul 23, 2009 06:06
While filtering grid takes value of the cell with getValue() method. While filtering "combo" cell getValue() returns not visible label, but actual option value. To change that behaviour you can implement custom filtering function. Please see more information here http://dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Data_filtering_search.html#grid_fsing
Answer posted by Pravu Mishra on Jul 23, 2009 06:51

Hi,

I do not find any additional information from the provided URL, that can be useful for filtering rows for any combo value in a grid .

Could you please provide a sample code?

Thanks and Regards,

Pravu Mishra.

Answer posted by Alex (support) on Jul 24, 2009 04:21

Hello, 

In case of combo excell a value of a cell are option keys. 

filterBy method allows to set filtering function. So, you can compare the grid value with the necessary value. 

mygrid.filterBy(1,function(cellval){
  return cellval==some_value;
})