Zee
Zee

Reputation: 8488

SAPUI5- Data binding not working

I am trying to bind data from controller to view but for some reason I am unable to display data in the view. I am setting the model using the following code:

var oModel = new sap.ui.model.json.JSONModel();
oModel.setData(oObject);
this.getView().setModel(oModel);
console.log("DATA:-->"+ JSON.stringify(this.getView().getModel().getData()));

The console statement prints the data properly but in the view the data is not appearing. Am I missing something. I am unable to find the problem.

My View:

.....
<form:SimpleForm
    id="iform"
    minWidth="1024"
    maxContainerCols="2" >
    <Label text="Name"/>
    <Text text="{NAME}"/>
    <Label text="Age"/>
    <Text text="{AGE}"/>
</form:SimpleForm>
.....

Thanks in advance.

Upvotes: 0

Views: 3476

Answers (1)

Haojie
Haojie

Reputation: 5713

Binding path should be {/0/Name} and {/0/AGE}

<form:SimpleForm
    id="iform"
    minWidth="1024"
    maxContainerCols="2" >
    <Label text="Name"/>
    <Text text="{/0/NAME}"/>
    <Label text="Age"/>
    <Text text="{/0/AGE}"/>
</form:SimpleForm>

Upvotes: 3

Related Questions