Skip to Content

Row Highlight in sap (ui table)Table

Hi Experts,

(Using sapuitable)

To Do -> Based on some conditions a table row needs to be highlighted out of 15+ records . Table should have the search/Sort/filter functionality and the highlight should work also .

I am now thinking of using 2 tables to display (1 with the best record and second table with all records.)

Any advise appreciated!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Feb 28 at 05:35 AM

    It's a bit more difficult (and a lot less streamlined) to conditionally highlight rows in an sap.ui.table.Table control since the aggregations are column based rather than row based. You would need to use jQuery in conjunction with custom CSS classes in order to highlight a row conditionally. This blog might be useful to you: https://blogs.sap.com/2014/10/07/coloring-table-cells-conditionally-in-sap-ui5/

    If you were to use sap.m.Table, the ability to conditionally highlight rows gets a lot easier since you can add an sap.ui.core.CustomData object to the items aggregation of the table, and have it write a key and value directly to the DOM for the row where the condition is met. Have a look at this blog: https://blogs.sap.com/2016/12/02/binding-based-dynamic-background-colors-for-sap.m.table-rows/

    I would recommend avoiding using sap.ui.table.Table for conditionally-highlighted rows if at all possible, since certain filter/sort/scroll operations can influence the DOM, and cause strange re-rendering issues since the CSS classes added with jQuery are not being managed by the SAPUI5 framework.

    Best Regards,

    Hunter Young

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 12 at 10:39 AM

    Thanks Hunter but i ahve already followed that blog and it partly worked for me and i have a done a workaround to highlight the row but as yu also pointed out during certain conditions(sorting filtering) the highlight donot work. So thats why i was wondering if i could use 2 tables .

    Meanwhile just to have a different view :-
    Requiremnt : i have around 20-30 columns in the same table to show . Any suggestion how to achieve that ?

    Add comment
    10|10000 characters needed characters exceeded