Can anyone with JS skills help me with a code to change font color from a field_X data if in the data the text “Blue”? I would like to apply it to all types of views.
And would be also cool to add an icon with the same color in the JS, but only if possible.
// Replace view_1 and field_2 with your view and field keys
//$(document).on(‘knack-view-render.view_1’, function(event, view, data) {
// $("#view_1 td.field_2").each(function() {
// #ff0000 is red and the #1c631f is green
// var textColor = ($(this).find(“span”).text().trim() == “Expired”) ? “#ff0000” : “#1c631f”;
// $(this).css(“color”, textColor);
// })
//});
I’m using this code, but if the text is not find, it apply the second color. I need to change the code to do not apply other color if the text is not found.
you can use the logical operators like OR (||) or AND (&&)
For eg.
var cordaequipe = ($(this).find(“span”).text().trim() != “Equipe Rosa” || “Equipe Verde” )?..
I hope this works
If not, you may have to use else if statmenent in the javascript
Seems I don’t get the logic you are trying to use.
Send me an email (gofredbrown@gmail.com) so we could discuss into details.
We will definitely put the outcome here