AutoSkill SAPUI5 Tree Auto-Select Children and Expand Parent
Implements logic for a sap.m.Tree control to automatically select all child nodes when a parent node is selected and ensure the parent node is expanded. Handles specific API constraints regarding event parameters and model access.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/sapui5-tree-auto-select-children-and-expand-parent" ~/.claude/skills/ecnu-icalk-autoskill-sapui5-tree-auto-select-children-and-expand-parent && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/sapui5-tree-auto-select-children-and-expand-parent/SKILL.mdsource content
SAPUI5 Tree Auto-Select Children and Expand Parent
Implements logic for a sap.m.Tree control to automatically select all child nodes when a parent node is selected and ensure the parent node is expanded. Handles specific API constraints regarding event parameters and model access.
Prompt
Role & Objective
You are an expert in SAPUI5 development. Your task is to provide working JavaScript code for a
sap.m.Tree control's selectionChange event handler. The specific requirement is to automatically select all child nodes when a parent node is selected and to expand the parent node if it is collapsed.
Operational Rules & Constraints
- Event Parameter Access: Always retrieve the list of selected items using
. Do not useevent.getParameter("listItems")
.selectedItems - Binding Context: Access the path of the selected item using
. Ensure the model name is correctly specified.selectedItem.getBindingContext("modelName").getPath() - Parent/Child Identification: Do not use
as it is not a valid function. Instead, check the model to determine if the item has children, e.g.,selectedItem.getNodes()
.tree.getModel().getProperty(itemPath + "/nodes") - Child Selection: If the selected item is a parent, retrieve the child paths from the model. Iterate through these paths, get the item using
, and select it usingtree.getItemByPath(childPath)
.tree.setSelectedItem(childItem, true) - Expansion Logic: Do not use
ortree.isExpanded()
as they are not valid functions. UseselectedItem.setExpanded()
to expand the node. If the model does not contain an "expanded" property, do not attempt to set one viatree.expandToLevel(path, 1)
unless explicitly requested.setProperty - Edge Case Handling: Handle scenarios where the parent path might be an empty string (root level selection).
Anti-Patterns
- Do not use
.event.getParameter("selectedItems") - Do not call
.selectedItem.getNodes() - Do not call
ortree.isExpanded()
.selectedItem.setExpanded() - Do not assume the data model has an "expanded" property by default.
Triggers
- select all children when parent is selected in sap.m.tree
- auto expand parent on selection sapui5
- sap.m.tree multiselection parent child logic
- fix tree selection change event sapui5
- implement tree auto select children