Skip to Content
Mar 13, 2017 at 03:10 PM

SAPUI5 Array update issue



I've a global Model for entire application. And a local model for one view. Array is in the global model.

1. Created view elements and binding with local model created on view

2. reading values from local model and trying to push to global model

Issue: very first element is pushing fine. But, when I try to push the second item to the global model, the first element which is already there in the model is updated with the new values entered on the screen. Am wondering, there is not binding though to global Model to get set by the framework.

Thought, to create local array in view controller itself and tried to push. Even, here also same thing is happening. when I read the model(model.getProperty) itself, the new values are directly getting updated to the model array.

var vModel = this.getView().getModel();
// Local Model
var vData = vModel.getProperty("/EduData");

var ownerComp = this.getOwnerComponent();
// Global Model 
var empModel = ownerComp.getModel("EmpData");
// Global Model Array
var EduDetails = empModel.getProperty("/Employees/EducationalInfo");

var eduModel = ownerComp.getModel("EduData"); // Local Model 
// Reading user input values
var modelData = eduModel.getProperty("/"); 

// Pushing to local Model
// Pushing to Global Model