1

I have a view, using sap.ui.table which has an editable vkorg column , these column is bound to a myModel4 model

XML view:

<u:Table rows="{myModel4>/BacklogHeaderSet}" busy="false" id="table40" rowMode="Interactive" cellClick="onCellClick" >
  <u:Column width="11rem" sortProperty="Vkorg" filterProperty="Vkorg">
    <Label text="Vkorg."/> <!-- The vkorg column -->
    <u:template>
      <Input xmlns="sap.m" value="{myModel4>Vkorg}" id="input41" valueLiveUpdate="true" liveChange="onChange" submit="onSubmit"/>
    </u:template>
  </u:Column>    

myModel4 is not created by default. There is a bind button when I press it will create the myModel4 model dynamically:

 onBind: function() {
    var oModel = new sap.ui.model.odata.v2.ODataModel("/sap/opu/odata/sap/ZBAJUSZ_ODATA_BACKLOG_SRV/", {
        defaultOperationMode: sap.ui.model.odata.OperationMode.Client
    });
    oModel.setDefaultBindingMode(sap.ui.model.BindingMode.TwoWay);
    var myTable = this.getView().byId("table40");
    myTable.setBusy(true);
    oModel.read("/BacklogHeaderSet", {
        success: function(response) {
            myTable.setBusy(false);
        }.bind(this),
        error: function() {
            myTable.setBusy(false);
        }
    });
    this.getView().setModel(oModel, "myModel4");
},

Running app screenshot

The model has a 2 way binding mode, and the input cell has valueLiveUpdate="true". My problem is that when I change the value of the Vkorg cell, the myModel4 value is not updated. It always contains the old value.

What can be the problem? Thanks for the help.

I tried to check the data after Submit and change event of the input field, but myModel4 not updated automatically,

I put a button on the screen, and on the press event I get the model values and write it into the console:

onLoopSO: function () { //Looping all entries of the table (binded to myModel4)
var oModel = this.getView().getModel("myModel4");
var oData = oModel.oData;
var oRecord;
var oTable = Object.getOwnPropertyNames(oData);
for (var i = 0; i < oTable.length; i++) {
oRecord = oTable[i];
console.log(oData[oRecord].Vbeln, oData[oRecord].Posnr, oData[oRecord].Vkorg);
}
},
4
  • How do you check that your model contains the old/new values? Commented Jan 2 at 9:03
  • I put a button on the screen, and on the press event I get the model values and write it into the console. I added the code into the question. Interesting, if I update the model VKORG value manually in the LiveChange event, then the model has the correct value. Commented Jan 9 at 9:12
  • It's because your model is a sap.ui.model.odata.v2.ODataModel (a server model). After change you need to submit change to backend. If you update directly data in your model , you can call oModel.submitChanges(); tu effectively do the changes Commented Jan 15 at 22:21
  • Are you sure about this? I mean, is it the correct behavior that you have a model and doesn't matter what you change on the screen, the model doesn't reflect the changes? Commented Jan 16 at 16:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.