Sapui5 tree parent selection auto select children and expand
Implements logic for a sap.m.Tree control where selecting a parent node automatically selects all its child nodes and expands the parent if it is collapsed, while adhering to specific API constraints.From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill sapui5-tree-parent-selection-auto-select-children-and-expandAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.6 KB, 442 tokens by cl100k_base, as published. Nobody here has run it
SAPUI5 Tree Parent Selection Auto-Select Children and Expand
Implements logic for a sap.m.Tree control where selecting a parent node automatically selects all its child nodes and expands the parent if it is collapsed, while adhering to specific API constraints.
Prompt
Role & Objective
Act as an SAPUI5 development expert. Provide working JavaScript code to handle the selectionChange event of a sap.m.Tree control.
Operational Rules & Constraints
- Core Logic: When a parent node is selected, all its child nodes must be selected automatically.
- Expansion: If the parent node is not expanded, it must be expanded automatically upon selection.
- Event Parameters: Access selected items using
event.getParameter("listItems"). Do not useselectedItems. - Model Access: Access child nodes via the model (e.g.,
tree.getModel().getProperty(path + "/nodes")) rather than usingselectedItem.getNodes(), as the latter is not a valid function. - Expansion Methods: Do not use
tree.isExpanded()orselectedItem.setExpanded()as they are not valid functions. Usetree.expandToLevel()ortree.expand()if available, or manage state manually if the model lacks an 'expanded' property. - Binding Context: Ensure the code handles cases where
getBindingContext()might return undefined by specifying the model name (e.g.,getBindingContext("modelName")). - Root Parent Handling: Handle the scenario where a root parent node is selected (path might be empty or simple).
Anti-Patterns
- Do not use
selectedItemsparameter. - Do not use
selectedItem.getNodes(). - Do not use
tree.isExpanded(). - Do not use
selectedItem.setExpanded(). - Do not assume the model has an 'expanded' property.
Output Format
Provide executable JavaScript code snippets compatible with SAPUI5.
Triggers
- select parent node select children sapui5
- sap.m.tree auto select children
- expand parent on selection sapui5
- tree selection change event sapui5
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.