Use filterItems(…) method to filter dhtmlxFolder items by some mask. Like with sorting, to create filter for dhtmlxFolders item you need to define function where you decide if item should be visible after filter applied or not. This function gets abstract item object as first incoming argument and mask as second argument. Function returns true if item should be visible, false if it shouldn't be.
For example XML representation of item in dhtmlxFolders is the following:
<item name="[string]" id="[string]"> <size>[numeric value]</size> </item>
To filter items which name begins with some value, we define the following function:
function filterByName(obj,mask){ var aName = obj.data.dataObj.getAttribute("name"); return (aName.toString().indexOf(mask)==0 || mask==""); }
Complete filtering command will be the following:
myFolders.filterItems(filterByName,"[mask value]");
To clear all applied filters use filterClear method:
myFolders.filterClear();
To apply filter keeping previous filters use the third argument of filterItems method:
myFolders.filterItems(filterByName,"[mask value]"); myFolders.filterItems(filterBySize,"[mask value]",true);
This code will filter items by name and then (keeping results of first filtering) by size.