Skip to Content
0
Former Member
Sep 18, 2014 at 10:25 AM

problem using two way binding of json model..

287 Views

Hey,

I am trying to bind sapui5 controls to a json model using bind value & bind property as shown

miApprovalDatePicker.bindValue("UIModel>/issueDate");
miApprovalDatePicker.bindProperty("value","UIModel>/approvalDate");

UIModel is the json Model which i have declared in my onit: of controller as shown

var UIModelCore = new woodsoftui5.model.MaterialIssueOrder();
        var UIModelJson = new sap.ui.model.json.JSONModel();
        UIModelJson.setData(UIModelCore);
        sap.ui.getCore().setModel(UIModelJson,"UIModel");

but i have a similar model which i use it to save data when i search using Ajax service where i am setting data to both UIModel & miModeljson

I am comparing if there is any change in UIModel & miModeljson in my save function as shown

 miSave: function (showPrintOrder) {
        var UIModel = sap.ui.getCore().getModel("UIModel");
    
       
        /****Checking if there is any change in values in ui and values obtained from data base*******************/
        if (!(_.isEqual(miModelJson.oData, UIModel.oData))) {.....Ajax call for save...}

the problem is that the values of the controls are also binding to miModelJson which i think a problem with twoWay binding which is new to me!!!!

The whole thing i am doing is to eliminate Ajax for Save,

please help...............

regards,

Raghu

thelJson