Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Dominic on Feb 17, 2008 03:16
open dhtmlx forum
custom filtering using custom select in grid header

I seem to have a simple problem, i.e. it should work but doesn't. I would like to filter a column with cells that may contain multiple items for the presence of which I would like to filter:

e.g. cell content like: " some string 1<BR>some string 2 "

on which mygrid.filterBy apparently won't work, since it seems to look for exact matches.


So what I want to do is define a custom dropdown/select in the header, just like in one of your answer in another post:

mygrid.attachHeader("A,<select onchange='mygrid.filterBy(1\\,this.value)'><option/><option value='1'>some string 1</option><option value='0'>some string 2</option></select>,C");

only that I want to call my own function, something like this:

mygrid.attachHeader("A,<select onchange='doFilter(1\\,this.value)'><option/><option value='1'>Yes</option><option value='0'>No</option></select>,C");

which then should call (here with an alert for testing purposes):

function doFilter(item) { alert("filtering for "+item.toString() ); };

The filter shows fine. However, this function is never called... can you tell me why? Would there be a better option for filtering? Combo seems to be the solution of choice ...

Sorry in case I am missing a simple javascript syntax problem - I do not have much experience with javascript.
Answer posted on Feb 18, 2008 02:31
>>However, this function is never called...
You code seems correct , and actually it works in my local sample ( html file attached )

>>on which mygrid.filterBy apparently won't work
filterBy can accept a "comparation function" instead of strict value

mygrid.filterBy(1,function(value){
    //comparation code here
    if (some_check(value)) return true;
    else return false;
});
Attachments (1)
sample.zip955.00 B