I am attempting to build a color-coded Tab Container in an Ignition perspective application that highlights status changes by changing the text color of individual tabs. Below is the configuration I’m using to change the tab.style.color parameter. I’m not getting an error but it’s not working. Any thoughts on what I’m doing wrong?
tip: surround your variable names with backticks to avoid markdown interpretation of character combinations: with backticks: tab[x].style...
, without: tab.style...
You're changing the value of a prop that doesn't exist. I'm not sure you can just change the color of the tabs, but you can use customized view instead of text.
The doc says:
If the element is changed to an object data type, then the text on the tab can be set by adding a text value member to the object and providing a string, as seen on element 0 below. Alternatively, viewPath (value data type) and viewParams (object data type) can be added to the element, which allows you to render a view inside the tab as well as pass parameters to it. Element 1 below demonstrates the idea. Keep in mind that the viewPath property will be ignored in favor of the text property if both exist in the object.
Make your view take a param for the text, and a param for the color, then you can change these parameters as much as you like. You can even add icons and whatnot, and change them dynamically.
.
I tried similar code by putting one of my tag paths in your same simple IF statement and just had it change the color of the font in a label, and it wouldn’t work. Perhaps it is not the tab color but the IF statement that is the problem. Maybe there is something magical in Ignition scripting or python that I’m not aware of, but that string will never be equal to the number 1 as far as I can tell.
You're absolutely right, that if
statement is wrong.