【发布时间】:2017-04-19 10:40:02
【问题描述】:
我在 SAPUI5 中向 SimpleForm 添加片段时遇到问题。我有一个 SimpleForm,想在表单中添加带有片段的内容。结果应如下所示: what i want done
我的片段:
<core:FragmentDefinition
xmlns="sap.m"
xmlns:core="sap.ui.core"
xmlns:mvc="sap.ui.core.mvc"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:l="sap.ui.layout"
xmlns:f="sap.ui.layout.form"
xmlns:tnt="sap.tnt"
xmlns:custom="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1">
<core:Title text="{i18n>beauskunftung.suche.address}"/>
<Label text="{i18n>beauskunftung.suche.streetNo}"/>
<Input editable="false" fieldGroupIds="Address" value="{AddressStreet}" id="inputStreetID"></Input>
<Input editable="false" fieldGroupIds="Address" value="{AddressStreetNumber}" id="inputNumberID">
<layoutData>
<l:GridData span="L3 M3 S4"/>
</layoutData>
</Input>
<Label text="{i18n>beauskunftung.suche.zipCity}"/>
<Input editable="false" fieldGroupIds="Address" value="{AddressZipCode}" id="inputZipID">
<layoutData>
<l:GridData span="L3 M3 S4"/>
</layoutData>
</Input>
<Input editable="false" fieldGroupIds="Address" value="{AddressCity}" id="inputCityID"/>
</core:FragmentDefinition>
如果我用 javacript 添加片段
var oFragment = sap.ui.xmlfragment("testistest", "com.natuvion.ddi.fragments.select.address");
var oLayout = this.getView().byId("AddressIDandSoOn");
oLayout.insertContent(oFragment, -1);
我收到以下错误:
未捕获(承诺)错误:“Element sap.ui.core.Title#__title0,Element sap.m.Label#__label0,Element sap.m.Input#testistest--inputStreetID,Element sap.m.Input# testistest--inputNumberID,Element sap.m.Label#__label1,Element sap.m.Input#testistest--inputZipID,Element sap.m.Input#testistest--inputCityID”对于 Element sap 的聚合“内容”无效。 ui.layout.form.SimpleForm#__xmlview1--AddressIDandSoOn
我认为问题在于 add 方法只能添加一个元素(如果我在片段中只有一个标签,它就可以工作!)。我寻找了一些应该包含片段中所有元素的元素,但我没有找到。如果我在页面上通过 XML 添加片段
<core:Fragment id="addressFragment1"
fragmentName="com.natuvion.ddi.fragments.select.address" type="XML">
</core:Fragment>
它有效。此时我不知道如何在 SimpleForm 中添加片段。我需要元素的动态生成,因为我必须根据给定的数据添加它,可能还要添加几次
我的问题: - 如何将片段添加到 SimpleForm?
【问题讨论】:
标签: sapui5