View level (this.getView().setModel(oModel, "hdrdata") Control level ( oControl.setModel(oModel) )
Different types of binding
--------------------------1) Model binding a) When there is only one model b) When there are multiple models
2) Entity Binding
3) Property Binding
For entity binding
------------------1) When we want to give entity name to the array var aData = [{lastName: "Dente", name: "Al", checked: true, linkText: "www.sap.com", href: "http://www.sap.com", src: "images/person1.gif", gender: "male", rating: 4}, {lastName: "Friese", name: "Andy", checked: true, linkText: "www.sap.com", href: "http://www.sap.com", src: "images/person2.gif", gender: "male", rating: 2}] var oModel = new sap.ui.model.json.JSONModel(); oModel.setData({modelData: aData}); set data to the model and give an entity name to that ,here "modelData" is an entity name given to aData , where aData is array of objects
to bind rows oTable.bindRows("/ModelData");
Entity Binding along with named Model to bind rows oTable.bindRows("ModelName>/ModelData"); In this case , for property binding we have to use model name ( ex : "{ModelName>PropertyName}"
2) If thers is an object which contains some entities and if we want
to bind one of those entity
var data = {SalesData:[{SalesOrder:"5000001", ItemNo:"00010",
var oSalesModel = new sap.ui.model.json.JSONModel();
oSalesModel.setData(data);
Set data to the model
oTable.setModel(oSalesModel); Set model to the view/control/global
oTable.bindRows("/SalesData"); Bind rows with entity SalesData
For Model Binding
-----------------------var oModel = new sap.ui.model.json.JSONModel(); oModel.setData(aData); set data to the model, here aData is an array of objects
Set model to the view/control/Global
oTable.setModel(oModel, "oModelData"); where oModelData is a model name to bind rows to the table oTable.bindRows("oModelData>/"); Steps to create table control(sap.m.Table) ------------------------------------------1) Create UI elements 2) Create row 3) add UI elements to the row 4) Create columns 5) Create table 6) Add columns to the table
7) set model to the table/view/global
8) bind items/rows
Steps to create table control(sap.ui.table.Table)
------------------------------------------------1) Create columns a) Bind lable b) Bind template