I am editing a custom widget but the search functionality is not working as intended so I need a little bit of help. This is a hierarchy custom widget and we are using UI5 to create the Tree View. So the problem is that when I search for a keyword it filters everything that doesn’t contain the characters but shows the parents of the nodes. What is required is actually the reverse, to hide the parents but show the children of the node that contains the characters (what is being searched).
So in a world hierarchy we have planet -> continent -> country -> cities
When searching for “France” I want to see all the cities (ex. Paris, Lyon, Lille, Nice, etc…)
France -> This is being Searched
Paris
Lyon
Lille
Nice
but right now its showing:
Earth
Europe
France -> This is being Searched
If someone can help on this issue I would appreciate the help. This is the code that I am using for the search.
onLiveChange: function (event) {
const query = event.getParameter("newValue").trim();
this.byId("Tree").getBinding("items").filter(query ? new sap.ui.model.Filter({
path: "text",
operator: "Contains",
value1: query,
}) : null);
this.byId("Tree").expandToLevel(9999);
}