cancel
Showing results for 
Search instead for 
Did you mean: 

How to hilight a Tile in SAPUI5 on Page load (not on any press event)

former_member243729
Participant
0 Kudos
1,037

Hi,

Have a requirement to highlight a tile (Generic Tile) based on a value in the model at run time (on load of the page and not on any press event). I know we can use CSS file to highlight the tile which I am able to do on press event but how to invoke a javascript function on load of this GenericTile and then add CSS class to it,..is what I am not getting. Below is what I have..

<GenericTile>

<tileContent>

<TileContent>

<Linktext="{path: 'oModel>Description'}"></Link>

</TileContent>

</tileContent>

</GenericTile>

Accepted Solutions (1)

Accepted Solutions (1)

former_member243729
Participant
0 Kudos

I could achieve this using below code.

this.getView().byId("idTile").addEventDelegate({
 onAfterRendering : function (oEvent) 
  {
var oModel = oEvent.srcControl.getAggregation('content').oPropagatedProperties.oBindingContexts.TempModel;
var sPath = oModel.sPath;

    if(oModel.getProperty(sPath).DefaultFlag)
       oEvent.srcControl.addStyleClass("selected");
  }
});

Answers (3)

Answers (3)

WouterLemaire
SAP Mentor
SAP Mentor

You could try to use the custom data property like I do in this blog: https://blogs.sap.com/2016/08/02/dynamic-cell-color-of-sapuitabletable-using-xml-views/


but in your case in combination with a tile control

Kr. Wouter

former_member243729
Participant
0 Kudos

In my case, based on the Text value the GenericTile should be highlighted. So if <Link text = "true"/> then the GenericTile should automatically highlighted. If the value is false then those Generic Tiles should not be highlighted.

<GenericTile>

<tileContent>

<TileContent>

<Linktext="{path: 'oModel>Description'}"></Link>

</TileContent>

</tileContent>

</GenericTile>

catano
Active Participant

Hi venkatasunil,

  • Give id to your tile:
<GenericTile id="myTile">
  • On load event in your controller access tile through view:
var oTile = this.getView().byId('myTile');
  • Add custom class to highlight tile:
oTile.addStyleClass('myCustomCssClass');

Regards,

Peter

catano
Active Participant
0 Kudos

Hi @ venkatasunil,
Did this solved your problem?

venkateswaran_k
Active Contributor
0 Kudos

Dear Venkata

Can you try the Generic tile as a KPI - which has some colour and indicator to highlight as below:

Refer to valueColor, Indicator

	<GenericTile class="yourcssclass"  tileLayout" header="Country-Specific Profit Margin" subheader="Expenses" press="onPress">
		<TileContent unit="EUR" footer="Current Quarter">
			<NumericContent scale="M" value="1.96" valueColor="Error" indicator="Up" withMargin="false" />
		</TileContent>
	</GenericTile>

Regards,Venkat

former_member243729
Participant
0 Kudos

I haven't tried this but this will not color the tile, it will only color the NumericContent.