cancel
Showing results for 
Search instead for 
Did you mean: 

sap ui5 filter and table row color?

Former Member
0 Kudos

hi all

i develop one application with odata and fill the table. also i color the row as per entity condition.

i put code in init(), afterrendering, on deligate, table updatefinish.i tried all thing. Color work first time but when try to fillter table then color not working?

need to write any extra code in upfatefinished?

thanks in advance

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member

Hi Nishanth,

How about writing the color code in the table onAfterRendering().

Regards,

Srinivasan

Former Member
0 Kudos

no not working..

Former Member
0 Kudos

var oTable = this.getView().byId("tblAllPo");

var aa = oTable.getBinding("items");

var aItems = oTable.getItems();

if (aItems && aItems.length > 0)

{ for (var i = 0; i < aItems.length; i++) {

var aCells = aItems[i].getCells(); // if (aCells[11].getText() === "NEW") { // debugger; // aItems[i].addStyleClass("redBackground"); // } if (aCells[11].getText() === "COMPLETED") { debugger; aItems[i].addStyleClass("greenBackground"); } if (aCells[11].getText() === "PARTIAL") { debugger; aItems[i].addStyleClass("blueBackground"); } if (aCells[11].getText() === "OVERDUE") { debugger; aItems[i].addStyleClass("LightCoralBackground"); } } }

former_member227918
Active Contributor
0 Kudos

sap.m.table or sap.ui.table ?

0 Kudos

Hi Nishanth,

If you are using sap.ui.table control, you can use the same logic on " Filter Event" for "color the row as per entity condition". So for every filter search, you will able to get "Color the row".

Try to write the "color the row" as a separate function. so that you can use on init() and filter event also.

Regards,

S. Sai Santhosh



Former Member
0 Kudos

i put color code in updateFinished="tofinish" at table event and it trigger as table refresh , means also after filter.


but suppose there is 10 records and after filter 5 reecords then still table model or data have 10 records and 5 its in binding items.


and table do color for 10 items.

Former Member
0 Kudos

var oTable = this.getView().byId("tblAllPo");

var aItems = oTable.getItems();

if (aItems && aItems.length > 0)

{

for (var i = 0; i < aItems.length; i++)

{

var aCells = aItems[i].getCells();

if (aCells[11].getText() === "GREEN") {

Former Member
0 Kudos

1.png result

0 Kudos

If your are using XML view table try to use formatter in your status column cell template.

 <Text text="{	path: 'invoice>Status',
		        formatter: '.formatter.statusText'
		     }"/>

in the formatter you can add your status color logic with CSS class

statusText: function(v){
   if(v === "OVERDUE"){
      this.addStyleClass("zStatusRed");
   }
   return v;
}

This will work for you and working for me.

For more information look at this link.. https://help.sap.com/doc/saphelp_uiaddon20/2.05/en-US/0f/8626ed7b7542ffaa44601828db20de/content.htm?...


s.sai.santhosh