我有一棵树,如下所示:
和XML视图:
<Tree id="classTree" items="{path: 'Tree>/'}" toggleOpenState="onToggleOpenState">
<CustomTreeItem>
<FlexBox width="100%" alignItems="Center" justifyContent="SpaceBetween">
<items>
<Label text="{Tree>text}" wrapping="true"/>
<Button icon="sap-icon://display" type="Transparent" press="onItemPress"/>
</items>
</FlexBox>
</CustomTreeItem>
</Tree>
如您所见,有一个带有事件press="onItemPress"
的按钮,其实现如下:
onItemPress: function (oEvent) {
const oRow = oEvent.getSource().getParent().getParent();
console.log(oRow.getItemNodeContext());
},
返回值是对象https://sapui5.hana.ondemand.com/#/api/sap.m.TreeItemBase/methods/getExpanded,that,具有以下值:
如何获取绑定到行的对象?
答案 0 :(得分:3)
那又怎么样:
oEvent.getSource().getBindingContext("Tree").getObject();