on 03-13-2017 3:10 PM
Hi,
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
vData.push(modelData);
vModel.refresh();
// Pushing to Global Model
EduDetails.push(modelData);
// Reading userinputvalues
var modelData = eduModel.getProperty("/"); // Pushing tolocal Model
vData.push(JSON.parse(JSON.stringfy(modelData)));
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ulrich, Thanks for coming back, binding and alias names everything is perfect. There is no error as such. But, the goal is, I want to read data from UI and push it to an array of the model. I will try to explain you bit more what is happening at the moment.
array A1 = [ { A B C }
{ X Y Z} ]
above is the data initially there in the model. Now, user is trying to add few more inputs and am reading them and adding using PUSH method.
{L M N} - this I've read from UI and pushed to A1 and L M N are added at the bottom as array element 2. first time it is fine. again user tried to add one more
{O P Q} - here onwards the issue starts. L M N will also be replaced by O P Q. All further elements will be replaced by the latest element values.
Now, the array A1 = [ { A B C }
{ X Y Z}
{O P Q}
{O P Q}] - please suggest.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What is the goal of this model manipulation? Would it be possible to use named models instead? At the setModel function you could use sth like:
oControl.setModel(oModel, "yourAlias");
At the data binding part use sth like:
"yourAlias>EduData/"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.