Skip to Content
Technical Articles
Author's profile photo Vikas Garg

Change table row background color in SAP Table based on condition using CSS


This Blog helps how to color table row conditionally in SAP UI5.


  1. Below Example is for SAP.m.Table
  2. We are trying to do this using CSS Only.


Step by Step Process:


In the below example we are changing Table Row color based on the File Status.

Step 1 :- After creation of our project, We need to add below library first : 





Step 2: – Once you are done with your table creation you need to add the Custom Data in the table for which you want to set the condition, In below code we are setting condition for “File status”. After adding Custom Data in the table, Table look like below:


<Table    id=”idTable114″   items=”{path:’/modelData’}”>







<Text text=” File Name” class=”text-white”/>







<Text text=” Date” class=”text-white”/>








<Text text=”File Status” class=”text-white”/>







<ColumnListItem id=”clm”>



<core:CustomData key=”mydata” value=”{File_Status}” writeToDom=”true”></core:CustomData>




<Text text=”{File_Name}”  />

<Text text=”{Date}”  />

<Text text=”{File_Status}”  />







Step 3:-  Add below code in your CSS File : 


background: #e97070 !important;

background: #7cdf5f !important;

background: #dcca3e !important;


Above CSS is used to set the color schema based on the different File status, We can change it as per our convenience.


Note:- No Need to make any changes in the Controller file. This conditional Table row color is based on the Custom data for the selected field and CSS.


Once We are done with above code changes, Our table should look like this :




Happy Coding !!!! 🙂 🙂 🙂


Vikas Garg




Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.