cancel
Showing results for 
Search instead for 
Did you mean: 

How to prevent auto update of model in UI5

0 Kudos

Hi, I have a simple form where user need to input the Product Name Short and Product Name Long.

I want to user click on Submit button once they have filled the information. The problem here, every time I entered the records, the data is being updated automatically to the back end (sending the batch request) without I need click the Submit button. How to prevent the automatic update ?

I am using two-way binding with oData version 4. here is my XML code and controller, and manifest.json

manifest.json:

"zearnModel": {
                "dataSource": "zearnService",
                "type": "sap.ui.model.odata.v4.ODataModel",
                "preload": false,
                "settings": {
                    "synchronizationMode": "None",
                    "operationMode": "Server",
                    "autoExpandSelect": true,
                    "groupId": "$direct"
                }
            },

JS Controller:

this.getView().addEventDelegate({
                onBeforeShow: function (evt) {

                    //this_.wasteTime();

                    var oModel = new sap.ui.model.json.JSONModel();
                    oModel = sap.ui.getCore().getModel("appid");

                    var app_id = oModel.getData().app_id;

                    this_.getView().byId("editapp").bindElement({
                        path: "zearnModel>/zearn_summary(" + app_id + ")"
                    });
                }
            });
        },

XML:

<mvc:View xmlns:mvc="sap.ui.core.mvc" controllerName="ARN.ARN.controller.EditApp" xmlns="sap.m" xmlns:form="sap.ui.layout.form"
    xmlns:core="sap.ui.core">
    <Page showHeader="true" title="{i18n>EditApplication}" showFooter="true" showNavButton="true" navButtonPress="doNavBack">
        <content>
            <Table tableId="userTable" id="editapp" growingThreshold="10" growing="true">
                <columns>
                    <Column>
                        <header><Label text="User ID"/></header>
                    </Column>
                    <Column>
                        <header><Label text="PRODUCT_NAME_SHORT"/></header>
                    </Column>
                    <Column>
                        <header><Label text="PRODUCT_NAME_LONG"/></header>
                    </Column>
                </columns>
                <items>
                    <ColumnListItem>
                        <cells>
                            <Input value="{path: 'zearnModel>APPLICATION_ID'}" name="APPLICATION_ID" editable="false"/>
                            <Input value="{path: 'zearnModel>PRODUCT_NAME_SHORT'}" name="PRODUCT_NAME_SHORT"/>
                            <Input value="{path: 'zearnModel>PRODUCT_NAME_LONG'}" name="PRODUCT_NAME_LONG"/>
                        </cells>
                    </ColumnListItem>
                </items>
            </Table>
        </content>
        <footer>
            <OverflowToolbar width="100%" height="46px" design="Auto" enabled="true" visible="true">
                <content>
                    <ToolbarSpacer width=""/>
                    <Button id="OKButton" text="{i18n>Save}" type="Emphasized" iconFirst="true" width="auto" enabled="true" visible="true"
                        iconDensityAware="false" press="onSave"/>
                    <Button text="{i18n>Reset}" type="Default" iconFirst="true" width="auto" enabled="true" visible="true" iconDensityAware="false"
                        press="onCancel"/>
                </content>
            </OverflowToolbar>
        </footer>
        <headerContent/>
        <subHeader/>
        <customHeader/>
    </Page>
</mvc:View>
0 Kudos

So it is not possible with two way binding?

mariusobert
Developer Advocate
Developer Advocate
0 Kudos

Hi Don,

correct, it's not possible as this is exactly the purpose of the two way binding feature

View Entire Topic
xstava
Explorer

Hi,

you need to add own updateGroupId, to bind parameter ... then you can submit batch with your groupId

parameters: {   
                           "$$updateGroupId": 'Stocktaking'
}
this_.getView().byId("editapp").bindElement({
                        path: "zearnModel>/zearn_summary(" + app_id + ")",
parameters: { "$$updateGroupId": 'Stocktaking'
}
});