Sapui5 从TableSelectDialog到表单的数据绑定
我正在使用TableSelectDialog查看一些运营商详细信息。我所需要的是:如果我选择了任何项目(行),那么该行中的所有值都应该自动填充到表单输入字段中Sapui5 从TableSelectDialog到表单的数据绑定,sapui5,Sapui5,我正在使用TableSelectDialog查看一些运营商详细信息。我所需要的是:如果我选择了任何项目(行),那么该行中的所有值都应该自动填充到表单输入字段中 在所附图像中,如果从TableSelectDialog中选择了Carrier Name,则应根据该值填充其余字段。您可以使用从TableSelectDialog接收的绑定上下文实现所需的功能 但为了使绑定上下文正常工作,表单和表选择对话框都应该引用相同的模型 以下是工作代码: VIEW.XML: 有一个按钮可触发“表格选择”对话框 有一
在所附图像中,如果从TableSelectDialog中选择了Carrier Name,则应根据该值填充其余字段。您可以使用从TableSelectDialog接收的绑定上下文实现所需的功能 但为了使绑定上下文正常工作,表单和表选择对话框都应该引用相同的模型 以下是工作代码: VIEW.XML:
handleClose
在handleClose
中,我们获取单击的项目绑定上下文,然后告诉表单:嘿!请参考此上下文(模型中存在)。绑定上下文有一个路径,告诉表单从何处进行相对绑定
请随时联系以获取更多信息
<l:VerticalLayout class="sapUiContentPadding" width="100%">
<l:content>
<Button class="sapUiSmallMarginBottom" text="Show Table Select Dialog"
press="handleTableSelectDialogPress">
</Button>
<VBox class="sapUiSmallMargin">
<f:SimpleForm id="SimpleFormDisplay354">
<f:content>
<Label text="Supplier Name" />
<Text id="nameText" text="{SupplierName}" />
<Label text="Description" />
<Text text="{Description}" />
<Label text="ProductId" />
<Text text="{ProductId}" />
<Label text="Quantity" />
<Text id="countryText" text="{Quantity}" />
</f:content>
</f:SimpleForm>
</VBox>
</l:content>
</l:VerticalLayout>
onInit: function () {
// set explored app's demo model on this sample
var oModel = new JSONModel(jQuery.sap.getModulePath("sap.ui.demo.mock", "/products.json"));
this.getView().setModel(oModel);
},
handleTableSelectDialogPress: function (oEvent) {
if (!this._oDialog) {
this._oDialog = sap.ui.xmlfragment("sap.m.sample.TableSelectDialog.Dialog", this);
}
this.getView().addDependent(this._oDialog);
// toggle compact style
this._oDialog.open();
},
handleClose: function (oEvent) {
var aContexts = oEvent.getParameter("selectedContexts");
if (aContexts && aContexts.length) {
// MessageToast.show("You have chosen " + aContexts.map(function(oContext) { return oContext.getObject().Name; }).join(", "));
this.byId('SimpleFormDisplay354').setBindingContext(aContexts[0]);
}
oEvent.getSource().getBinding("items").filter([]);
}