cancel
Showing results for 
Search instead for 
Did you mean: 

getView().getModel() getting undefined

Former Member

Hi All, I am trying to bind the elements with my json Object. Firstly i have created an Array of Object and set this object in this.getView() using: newArray.push({'startdate': '20-08-2015', 'end_date':'20-09-2015'}); var model =  new JSONModel(); model.setData(customObject);         this.getView().setModel(newArray,'project'); this.getView().bindElement('/project/0'); I am not able to bind the data object with my xml view. I think the problem is with model, when i am trying to console(this.getView().getModel()), it is giving me undefined. I am not able to find out where to set the model in the controller so that i can bind the object with xml. Regards, Harsh Jain

Accepted Solutions (0)

Answers (2)

Answers (2)

santhu_gowdaz
Active Contributor

this.getView().setModel( new JSONModel(newArray),'project');

console.log(this.getView().getModel("project"));

Former Member
0 Kudos

Hi Santhosh, Thanks for the reply. I have also tied that but still not able to bind the object with elements this.getView().bindElement('/project/0'); How to bind the elements here ? Regards, Harsh Jain

saivellanki
Active Contributor
0 Kudos

Hi Harsh,

Try -


this.getView().bindElement("project>/0");

Regards,

Sai Vellanki.

Former Member
0 Kudos

Hi Sai Vellanki, Thanks for the reply, I have tried this, but still not able to get the result 😞 I think, am not able to set the model to get the object. After setting the model when i am trying to get the Model, it showing "undefined". That's why the binding is not giving me the result. Regards, Harsh Jain

Former Member
0 Kudos

Because it should be:

  1. this.getView().bindElement("{project>/0}"); 
former_member182372
Active Contributor
0 Kudos

this.getView().setModel(model ,'project');


NOT


this.getView().setModel(newArray,'project');



and


  1. this.getView().bindElement("project>/0"); 

should work after that