Hi All,
I have a requirement in which I need to create dynamic tiles based on Odata. I have acheived the same.
Now I have another requirement where in I need change the background color of the tiles based on content in the tile. I am trying to access the content of the tilecontainer and trying to add the style class for each tile, however my Tilecontainer is shown as empty although I can see the tiles on my page.
Below is the code
var tileContainer = new sap.m.TileContainer("tileContainer",{ height:"40%", allowAdd : true, editable : false }); var templateTile = new sap.m.StandardTile({ title : '{COUNT}', number:'{STATUS}', info:'{STRTDATE}', icon:"sap-icon://bar-chart", }).addStyleClass("test"); oModel = sap.ui.getCore().getModel(); tileContainer.setModel(oModel); tileContainer.bindAggregation("tiles",{path : "/Orders", filters: [f1, f2], template: templateTile}); new sap.m.App({ pages : new sap.m.Page({ enableScrolling : false, content : [tileContainer] }) }).placeAt("content"); // Below code is for accessing the tiles in the TileContainer and adding style class to them
var tiles = tileContainer.getTiles(); if (tiles != null){ for ( i = 0; i < tiles.length; i++){ if(tiles[i].getTitle = "CANCELLED"){ tiles[i].addStyleClass("test"); } } }