I am trying to change the background color of the row based on the cell valuebut this is not working when i'm giving this style to Style rowIf(
GetAttendanceRequestForSpecificUser.List.Current.AttendanceRequest.StatusId = Entities.Status.Pending,
"background-color: white",
If(
GetAttendanceRequestForSpecificUser.List.Current.AttendanceRequest.StatusId = Entities.Status.Approved,
"background-color: green",
GetAttendanceRequestForSpecificUser.List.Current.AttendanceRequest.StatusId = Entities.Status.Rejected,
"background-color: red",
""
)
Can Anyone tell why is it not working and what i have to do
Hi @Prem Ganwani ,
1) you can't style individual rows based on data by using the table's style row property.
Any conditions in this styling is only evaluated once, and so when you refer to the current record in a list there, it always looks at the same (if you have done nothing other than retrieving from the database, that will be the first row.)
You'd have to style at the cell level (so repeat it for every cell)
2) try using classes over inline styling when possible
3) if you go the way of doing it per cell, please do something to avoid having the same logic repeated multiple times (either a client side function, or a calculated attribute in the sql (this maybe goes against separation of content from form, but I think is still preferrable over repeating the logic)
4 another way is not to bring presentation stuff into your aggregate, but bring data into your presentation, (this also kind of goes against separating content from form, but i like it better, as I rather have the form know about the content, then the content know about the form) :
* add your status value as a data property to one of the cells in your row
my example is for IsActive, but you can just use status, i would however translate the statusids into someting human readable in the css, so someting like
data-request-status :
if (xxxxxxx.statusid = Entities.Status.Pending, "pending",
if (xxxxxxx.statusid = Entities.Status.Approved, "approved",
if (xxxxxxx.statusid = Entities.Status.Denied, "denied",
"request-is-unknown-status")))
* If you want to limit this styling to only specific tables, you could add an extra class at the table level (I like to do that, for this example, not as urgent, as it is unlikely that other tables would have that data element somewhere in their cells)
* in the css :
so
you either target a specific table class or not, dependent on how carefull you want to be
you target only table rows that have that data attribute with a particular value
you style each individual td inside the tablerow, this is needed because of specificity compared to the Outsystems UI
so in your case, there would be 3 rules like
.table-colored .table-row:has([data-request-status = "pending"]) td{}
Dorine
Thanks for your guidance! Your directions were instrumental in customizing the code. Much appreciated!
Best regards, Prem
Best regards,Prem
Hi @Prem Ganwani,
Please try this
add your CSS class/Style whatever you want to cell
Result:
I am attaching OML also.
Hope this will help you.
Note: I have added conditions with my name If(GetUsers.List.Current.User.Name="Sanjay kushwah","background:red","background:grey") My name will not be available in your Database so you will see same color(ie. grey) of each row so please alter condition according to your requirements