簡體   English   中英

創建表格不起作用sapui5

[英]Create form doesn't work sapui5

我有一個使用OData服務的主從應用程序。

我還有一個名為“ DetailCreateMode.fragment.xml”的片段中的創建表單,該表單應該創建通知。 不幸的是,它不會創建它們。

這是我的片段:

 <core:FragmentDefinition height="100%" width="100%" xmlns="sap.m" xmlns:core="sap.ui.core" xmlns:l="sap.ui.layout"     xmlns:f="sap.ui.layout.form">
<Panel>
<content>
<f:SimpleForm id="iconTabFilter1form" minWidth="1024" editable="false" layout="ResponsiveGridLayout" labelSpanL="3" labelSpanM="3"
            emptySpanL="4" emptySpanM="4" columnsL="1">
            <f:content>
                <Label text="Equipement" required="false"/>
                <Input name="Equnr" id="Equnr_id" valueLiveUpdate="true" liveChange="_validateSaveEnablement"
                enabled="false" visible="true"
                value="{ path: 'Eqktx', type: 'sap.ui.model.odata.type.String' , constraints:{ maxLength:18, nullable:false } }"/>

                <Label text="Désignation" required="true"/>
                <Input name="Qmtxt" id="Qmtxt_id"     valueLiveUpdate="true" liveChange="_validateSaveEnablement"
                enabled="true" visible="true"
                value="{ path: 'Qmtxt', type: 'sap.ui.model.odata.type.String' , constraints:{ maxLength:40, nullable:false } }"/>

                <Label text="Date Avis" required="true"/>
                <DatePicker id="Qmdat" displayFormat="short" change="_validateSaveEnablement"
                 value="{ path: 'Qmdat', type: 'sap.ui.model.type.Date', formatOptions: { style : 'long' }  }"/>    

            </f:content>
        </f:SimpleForm>
    </content>
</Panel>

這是保存和創建的按鈕:

<Button id="saveButton" press="saveChanges" icon="sap-icon://save"></Button>

最后但並非最不重要的,這是詳細控制器中的功能:

saveChanges: function() {
    var oModel = this.getView().getModel();
    var mNewEntry = {};

    mNewEntry.Equnr = sap.ui.getCore().byId("Equnr_id");
    mNewEntry.Qmtxt = sap.ui.getCore().byId("Qmtxt_id");
    mNewEntry.Qmdat = sap.ui.getCore().byId("Date Avis");
    oModel.create("/avisSet", mNewEntry, null, function(oData){
        MessageBox.show(
            "Created succesfully",{
            icon : sap.m.MessageBox.Icon.SUCCESS,
            title : "Dear User",
            styleClass : "sapUiSizeCompact"
            }
            );
    }, function(err){
        MessageBox.show(
            "ERROR",{
            icon : sap.m.MessageBox.Icon.ERROR,
            title : "Dear User",
            styleClass : "sapUiSizeCompact"
            }
            );
    }
    );
      oModel.refresh();  
    },

如果我猜測,我會說值mNewEntry.Equnr,...是未定義的

請更改此:

 mNewEntry.Equnr = sap.ui.getCore().byId("Equnr_id");
 mNewEntry.Qmtxt = sap.ui.getCore().byId("Qmtxt_id");
 mNewEntry.Qmdat = sap.ui.getCore().byId("Date Avis");

對此:

 mNewEntry.Equnr = this.byId("Equnr_id");
 mNewEntry.Qmtxt = this.byId("Qmtxt_id");
 mNewEntry.Qmdat = this.byId("Date Avis");

編輯17:10 140317:

例:

https://sapui5.hana.ondemand.com/explored.html#/sample/sap.ui.layout.sample.SimpleForm480_Trial/preview

您將需要獲取輸入的值,如下所示:

mNewEntry.Equnr = sap.ui.getCore().byId("Equnr_id").getValue();
mNewEntry.Qmtxt = sap.ui.getCore().byId("Qmtxt_id").getValue();
mNewEntry.Qmdat = sap.ui.getCore().byId("Date Avis").getValue();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM