Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
we have an IBA and it has a custom datautility. It returns a JSONComponent object , how can we use this datautility dynamically change the background color of the attribute?
Hello @spitchan
I usually used Label to set a text color (com.ptc.core.components.rendering.guicomponents.Label)
First you define a CSS style with own name in a windchill-base.css.
Then in DataUtility use labelSet.addStyleClass("NAME OF CSS CLASS");
labelSet.addStyleClass("overdueDate"); // overdueDate is ootb style to change color text to red.
in css style you can define the background color.
background-color: #FF0000;
Hope this can help
Best Regards
try {
json = new JSONObject(str);
WTProperties wTProperties = null;
wTProperties = WTProperties.getServerProperties();
String str1 = wTProperties.getProperty("wt.server.codebase");
// json.put("iconPath", str1 + "/netmarkets/images/chgnotice.gif");
String str3 = this.rf.getReferenceString(wTReference);
json.put("link", "app/#ptc1/tcomp/infoPage?oid=" + str3 + "&tabType=custom&tabAction="
+ getChangesTabId());
json.put("label", chorder.getNumber());
json.put("value", chorder.getNumber());
json.put("title", chorder.getNumber());
json.put("type", "url");
json.put("style", "background-color:red");
JSONObject json2 = json;
// json2.put("type", "icon");
// json2.put("iconPath", str1 + "/netmarkets/images/chgnotice.gif");
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
str = json.toJSONString();
System.out.println(" Print me : --------" + str);
}
System.out.println(" Print me 2: --------" + str);
if (str == null)
return "";
}
}
return str;
this is the code we use for datautility. we have no css/ jsp. I tried and not working.
Hello @spitchan
As I mentioned I usually used different type of object to return. So I do not have experience with json in datautility and no idea how the structure should looks like.
I guess that just add a style could not work. The target place (page/table what ever) has to process that json and if the target place can not read it it can not work as you expect. (style is not parameter in GuiComponent)
css style is used in any place in a Windchill system (windchill-base.css). so try to use it as I described.
Maybe json.put("styleClasses", "{overdueDate}"); could work. Try it. (overdueDate is defined css class to change text to red and bold) btw styleClasses should be an ArrayList
PetrH
Hi @spitchan
Just example how the css works in my test system
defined css style in Windchill\codebase\netmarkets\css\windchill-base.css
set in DataUtility as AV-GREEN
result in the Windchill
Best Regards
PetrH