Use `setCriteria` on TreeGrid and include children

70 views Asked by At

Our TreeGrid has a search filter which calls this method

var aCriteria = {
    _constructor: "AdvancedCriteria",
    operator: "and",
    criteria: [
        { fieldName: "EntityName", value:entityFilterFindForm.getValue("find"), operator: "iContains" }
    ]
};
this.creator.entityFilterTree.setCriteria(aCriteria);

This works great to show the target node and all parents of the target node. Unfortunately this gives the illusion that the target node has no children, is it possible to still offer the ability to expand children of the target node?

UPDATE

The solution we had was to include a pipe delimited value of ancestors coming out of SQL and include that parameter in our criteria to search. That way the children of our search result would be included because the search string was found in their ancestor string.

1

There are 1 answers

1
claudiobosticco On

I've never tried it, but reading the docs for Tree.getFilteredTree I see a parameter 'filterMode', which has two valid values:

"strict" only nodes that actually match criteria are shown. If a parent does not match the criteria, it will not be shown, even if it has children that do match the criteria

"keepParents" parent nodes are kept if they have children which match the criteria, or, in a tree with loadDataOnDemand:true, if they have not loaded children yet.

Maybe keepParents could work for your use case?

Sorry, I just realized you already have parents, but you want children. Did you already try a call to Tree.loadChildren or reloadChildren ?