I have some implementation where I loop over an array of objects and create a new GenericTile for each object. I need to set the blocked property of the tile dependant of the objects Count property.
I tried to use some expression binding for this but I get the following error:
"true" is of type string, expected boolean for property "blocked" of Element sap.m.GenericTile#exampleTile0
Since my data is not in a model but in an object I try to use some variable in the expression binding. I did not find any example for this case so I am not sure if this can even work or if I need to create a new model (at least the error text sounds for me like the variable is interpreted).
Here is my relevant code:
for (var i = 0; i < aExampleData.length; i++) {
var oNewTile = new GenericTile("exampleTile" + i, {
tileContent: new sap.m.TileContent({
content: new sap.ui.layout.HorizontalLayout({
content: [
new sap.m.Title({
text: aExampleData[i].Name
}),
new sap.m.Text({
text: aExampleData[i].Description
}),
new sap.m.HBox({
items: [
new sap.m.Text({
text: that.getResourceBundle().getText("count")
})
new sap.m.Text({
text: aExampleData[i].Count
})
]
})
]
})
}),
blocked: "{=" + aExampleData[i].Count + "> 0 ? false : true }"
});
this.byId(xxx).addItem(oNewTile);
}
Can someone give me a hint how to solve this? Thanks!
blocked: aExampleData[i].Count <= 0? If you want to do it in a more proper "UI5 way", you will probably have to put the data in a JSONModel and bind the parent of the Tiles to it. - TiiJ7.set/getBlockedare private APIs and the propertyblockedishidden(See github.com/SAP/openui5/commit/…). I'd suggest to avoid using this property. - Boghyon Hoffmann