onInit: function(){
var arr = [{
"Name":"a",
"City":"w",
"Amount":10,
},
{
"Name":"b",
"City":"x",
"Amount":2,
},
{
"Name":"c",
"City":"y",
"Amount":0,
},
{
"Name":"d",
"City":"z",
"Amount":0,
},];
var demoModel = new sap.ui.model.json.JSONModel({
"results": arr
});
this.getView().byId("ID_DEMO").setModel(demoModel,"demoModel");
}
<Table visible="true" id="ID_DEMO"
items="{ path:'demoModel>/results',factory:'.myFactory'}">
<columns>
<Column minScreenWidth="Tablet" demandPopin="true">
<Text text="Name" />
</Column>
<Column minScreenWidth="Tablet" demandPopin="true">
<Text text="City" />
</Column>
<Column minScreenWidth="Tablet" demandPopin="true">
<Text text="Amount" />
</Column>
</columns>
</Table>
myFactory :function(sId,oContext){
var Value = oContext.getProperty("Amount");
var element;
if(Value > 0){
element = new sap.m.Text({
text:"{demoModel>Amount}"
});
}
else{
element = new sap.m.Input({
value:"{demoModel>Amount}"
});
}
return new sap.m.ColumnListItem({
cells:[new sap.m.Text({
text:"{demoModel>Name}"
}),
new sap.m.Text({
text:"{demoModel>City}"
}),
element
]
});
},
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 |