如何将元素绑定到SmartForm?

时间:2018-11-27 13:34:21

标签: sapui5

我有以下对话框:

<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core" xmlns:f="sap.ui.layout.form" xmlns:l="sap.ui.layout"
    xmlns:smartField="sap.ui.comp.smartfield" xmlns:smartForm="sap.ui.comp.smartform">
    <Dialog id="massChangeDialog" title="{i18n>ChangeMaintainanceOrderOperation}" resizable="true" draggable="true" contentWidth="900px"
        contentHeight="700px">
        <content>
            <smartForm:SmartForm id="editOperation" editable="true" entityType="EditOperation">
                <smartForm:Group>
                    <smartForm:GroupElement>
                        <smartField:SmartField value="{WorkCenter}"/>
                    </smartForm:GroupElement>
                </smartForm:Group>
                <smartForm:Group>
                    <smartForm:GroupElement>
                        <smartField:SmartField value="{PersonalNumber}"/>
                    </smartForm:GroupElement>
                </smartForm:Group>
                <smartForm:Group>
                    <smartForm:GroupElement>
                        <smartField:SmartField value="{ActionDescription}"/>
                    </smartForm:GroupElement>
                </smartForm:Group>
                <smartForm:Group>
                    <smartForm:GroupElement>
                        <smartField:SmartField value="{ChangedDate}"/>
                    </smartForm:GroupElement>
                </smartForm:Group>
                <smartForm:Group>
                    <smartForm:GroupElement>
                        <smartField:SmartField value="{ChangedTime}"/>
                    </smartForm:GroupElement>
                </smartForm:Group>
            </smartForm:SmartForm>
        </content>
    </Dialog>
</core:FragmentDefinition>

,并希望将SmartForm绑定到上下文。

在控制器中,有一个pressChangeButton在进行上下文绑定:

pressChangeButton: function (e) {
    this.getView().setModel(this.getModel("EditOp"), "Op");
    .......
    this.oDialogChangeOperations = this.getView().byId("massChangeDialog");
    if (!this.oDialogChangeOperations) {
        // Begin of 0001
        this.oDialogChangeOperations = sap.ui.xmlfragment(this.getView().getId(),
            "rsh.eam.details1.RSH_EAM_DETS1Extension.view.ChangeOperationsCustom", this);
        // End of 0001
        this.getView().addDependent(this.oDialogChangeOperations);
    }
    if (sap.ui.Device.system.phone) {
        this.oDialogChangeOperations.setStretch(true);
    }
    this.byId("editOperation")
        .bindElement({
            path: "/EditOperationSet(1)",
            model: "Op"
        });
    this.oDialogChangeOperations.getModel("Op").attachBatchRequestCompleted(this.onBatchRequestComplete, this);
    .......
},

第一行,我将OData模型EditOp设置为视图Op,其定义如下:

enter image description here

enter image description here

在线:

this.byId("editOperation")
    .bindElement({
        path: "/EditOperationSet(1)",
        model: "Op"
    });

我将SmartForm绑定到模型“ Op”,该模型指向OData服务。

最后,我有一个空的SmartForm,应该显示在红色边框内。

enter image description here

我在做什么错?

1 个答案:

答案 0 :(得分:0)

您需要调用对话框的open()方法。