Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by richard white on Mar 10, 2009 08:19
open dhtmlx forum
filtering in tree grid

hi

we have a tree grid that has most of its items on the top level (like a normal grid) but a few items have sub children (only 1 level down).

we have added filters to the columns and notice that when we type in a criteria it finds the normal grid rows, the sub children, but does not even look at the items that are classed as parents

we need the functionality for the user to type in a criteria and it looks at all items in the tree grid (normal grid rows, parent items, and level 1 children).

can you tell us how to do this please, or if not possible can you help us with a work around

thanks
Answer posted by dhxSupport on Mar 10, 2009 10:16
You can use mygrid.setFiltrationLevel(-2) method which allow you to filter at all levels
Answer posted on Mar 10, 2009 10:55
thanks for this.

we have placed the code just after the filters have been added, as follows:

grid.attachHeader(",#text_filter,#text_filter,#select_filter,#text_filter");
grid.setFiltrationLevel(-2);

but we get the following error

this.filters is undefined
_loadSelectOptins()()dhtmlxgr...filter.js (line 30)
setFiltrationLevel()("-2", undefined, undefined)dhtmlxtr...filter.js (line 11)
(?)()()index.cfm (line 7655)
_launchCommands()([call 0=call])dhtmlxgrid.js (line 533)
_parseHead()(rows)dhtmlxgrid.js (line 539)
waitLoadFunction()()dhtmlxcommon.js (line 15)
}},500)}};if (id.parentNode)id.parentNo...[0].tagName.toLowerCase()){case "input":

thanks

Answer posted by Support on Mar 11, 2009 02:33
According to above code you calling the command from XML, right?
Please be sure to place command in "afterInit" section
Answer posted on Mar 11, 2009 06:07
thanks, we placed this in the afterinit section

it displays some strange behaviour though

the values a parent is tb_33 for example then all of its children have tb_33a etc..... and when we type 'tb_' into the filter box then it works fine as it places the parent node first then all children come after it. however if we type just 'tb' (without the underscore) then it shows all sub children first and then the parent at the bottom

is this a bug?

thanks
Answer posted on Mar 11, 2009 06:13
also, it doesnt filter on tree items that are not open

thanks
Answer posted by Support on Mar 11, 2009 06:28
>>also, it doesnt filter on tree items that are not open
Known issue , if you are using smartXMLParsing mode
You can disable such mode , or add custom code to onOpenEnd event, which will call grid.filterByAll() to reapply filtering to newly rendered branch. 
Answer posted by Support on Mar 11, 2009 06:30
>>it displays some strange behaviour though
Unfortunately issue can't be reconstructed locally. If it still occurs for you - please provide a sample of data ( xml ) for which issue occurs. 
In normal case , filtering must not change order of parent|child elements, just change their visibility. 
Answer posted on Mar 11, 2009 06:33
sorry i dont understand what you mean by:

>> or add custom code to onOpenEnd event, which will call grid.filterByAll() to reapply filtering to newly rendered branch.

this means that they still have to open the nodes though right?
Answer posted by Support on Mar 11, 2009 07:26
"onOpenEnd" event raised immideatly after item in tree got command to open/close , and before item was opened//closed. Event also raised for unclosable nodes and nodes without open/close functionality - in that case result of function will be ignored.
Answer posted on Mar 11, 2009 07:33
so in the case of this problem, what code do i need to add in order to get it to also filter by un-opened nodes? i would appreciate an example as i am confused

thanks
Answer posted by Support on Mar 11, 2009 10:16
>>>> or add custom code to onOpenEnd event, which will call grid.filterByAll() 
You can use code as

grid.attachEvent("onOpenEnd",function(){
    this.filterByAll();
    return true;
})

as result, each time, after branch opening, filtering will be reapplied ( all #text_filter, #select_filter and etc. ) , so newly opened branch will be filtered same as all treegrid