Sapui5 如何获取已单击项的绑定上下文?

Sapui5 如何获取已单击项的绑定上下文?,sapui5,Sapui5,我有一个表,如下所示: 关于以下内容的代码: 视图: 事件处理程序: handleItemPress:功能oEvent{ //console.logoEvent.getSource.getMetadata.getName; //console.logoEvent.getSource.getSelectedItem; }, handleListPress:功能oEvent{ console.logoEvent.getSource.getObjectBinding;//返回null console.

我有一个表,如下所示:

关于以下内容的代码:

视图:

事件处理程序:

handleItemPress:功能oEvent{ //console.logoEvent.getSource.getMetadata.getName; //console.logoEvent.getSource.getSelectedItem; }, handleListPress:功能oEvent{ console.logoEvent.getSource.getObjectBinding;//返回null console.logoEvent.getSource.getBinding;//返回null console.logoEvent.getSource.getBindingContext;//返回null }, 我想要达到的是,当我按下列表中的一个项目时,比如瑞士分部,我想要得到绑定的上下文。正如您在视图中看到的,列表绑定到OData服务

使用UI5浏览器工具,您可以看到列表已绑定到上下文:

如何从单击的项目中获取绑定上下文?

使用两个API并等待模型名称作为参数。即,在您的情况下,它应该是:

handleItemPress:functionevent{ const clickedItem=event.getParameterlistItem; const context=clickedItem.getBindingContext/*modelName*/ac;//给定项={ac>…} }, API和API都将等待模型名称作为参数。即,在您的情况下,它应该是:

handleItemPress:functionevent{ const clickedItem=event.getParameterlistItem; const context=clickedItem.getBindingContext/*modelName*/ac;//给定项={ac>…} },
这回答了你的问题吗?这回答了你的问题吗?