Skip to main content

I want to set conditional formatting on the Priority field on the standard Task object. If the priority is High, I want to add a class to the HTML element so that I can apply custom CSS through the class. I’ve read various posts here that are similar to this need, but I’m having trouble extrapolating from them. My attempt so far is to use a custom field renderer on the Priority field in my table of Tasks and to call the JQueryUI function addClass(). Here’s my inline snippet that I’m using as the custom field renderer. Am I in any way on the right track? var field = argumentsr0], value = argumentsr1]; if (field.mode == ‘read’ && field.value == ‘High’) { field.addClass(“highpriority”); }

Ryan,

I was able to get this working in the end for me. I had to pick one field on the table and render it as the snippet to get this working. Do you have one of your fields rendering as this snippet, because your code looks okay to me…


That worked thanks! I didn’t assign the snippet to a separate field.


No problem! Glad to help!


I’ve used this on a bunch of tab pages successfully. Is there any reason it wouldn’t work on a table on a detail page? If not I can’t see where I have gone wrong. I have tried with the field on the table and without. Same logic, highlight a row where a checkbox is marked as true. 

I’ve tried read/readonly. 

Snippet:

var field = arguments 0];var value1 = arguments 1];
var row = field.row;
var value2 = row.Flag__c;

skuid.ui.fieldRenderersdfield.metadata.displaytype]field.mode

if ((field.mode == ‘readonly’) && (value2 === true))



field.item.element.addClass(“flag_highlighted-row”);

}

CSS:

table.nx-skootable-data tbody tr.flag_highlighted-row td {    
   background-color: #ffffcc;

}


I am using a very similar script on a table without issue. I could be mistaken but maybe change this line


if ((field.mode == 'readonly') && (value2 === true))


to


if (field.mode == 'readonly' && value2 === true)

Thanks. Just tried it but still didn’t work unfortunately. 


Hi Emily, I am having the same issue Matt did. The render is correctly applying the css class but the table won’t change. Except I used your suggestions for the css selector already. CSS is: table.nx-skootable-data tbody tr.LeadTab_highlighted-row td { background-color: LightCoral; } Snippet is : var field = argumentst0], value = skuid.utils.decodeHTML(argumentst1]); skuid.ui.fieldRenderersrfield.metadata.displaytype]field.mode; if (field.mode == ‘read’ && value === true) { field.item.element.addClass(“LeadTab_highlighted-row”); }557712f8b7ee2cd512049be15d82e14b3e683ede.png


If the class is being applied but you are not getting the expected results - it either is because the class is not defined correctly (and all the properties are getting thrown out) or it is because there is another div sitting on top of your special one that is blocking it. 


Your second idea worked. There was a problem with the CSS used in a map I had on the page. I thought I had tested it without the map already. Works now thanks!


I want to do this but is there a new way or where can I find the sample page that was created. Link is dead


Chad - we moved things around in our Sample Page repo this year. Here is a corrected link to the Conditional Row Highlighting page:


https://github.com/skuid/SamplePages/blob/master/xx_Holding/Conditional%20Row%20Highlighting%20(Lead%20List)


A note. In our upcoming release we will be delivering declarative ways to do this in the V2 page api. We already have conditional styling that can be applied to components. So you could already change the background color of a form if “do-not-call” = true. But what is coming is targeting individual table fields or rows with this styling change.


I don’t know if you are exploring the V2 API at all - (I hope you are cuz its awesome!) - but you might consider that…


Its good to see you here. I hadn’t heard your name in a while… Hope the app is doing well.


thanks for the help. good to be seen