Hi
I am currently evaluating DHTMLX and I am trying to change a label text colour dynamically based on wetter I click on a checkbox. Ideally i would like to be able to use the form forEachItem function to switch all labels to a different colour.
this is ideally what i would like to do, I didn’t found how:
var theItem;
myForm.forEachItem(function(id, radioValue){
if(myForm.getItemType(id)==‘label’){
theItem = myForm.getItem ( id ); // this function doesn’t seem to exist
theItem.className = ‘myClassRed’; // or others colour that I will define.
}
}
I don’t want to use the validation function cause I need to be able to change the colour at any time to different colour.
Thanks I tried that but unless I miss something, the next time you call getItemLabel, it now contains the ‘style’ extra code so I have to have special code to handle the first time setting it or when it was already set.
// init
{type: "label", name: "myLabel", label: "Some text here"}
// change color
myForm.setItemLabel("myLabel", "<span style='color:red;'>New label</span>");
myLabelText = myForm.getItemLabel("myLabel");
console.log ( myLabelText ); // will output "<span style='color:red;'>New label</span>"
in my case, I want to have a function that change the labels colours that use the colour in parameter. Right now, next time I call it, I end-up with:
The first time it work, but second time it doesn’t as explained above. I was trying to find a clean way of doing it without having to put an exception in the code.