cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

How to highlight or change the background color of an attribute using datautility?

spitchan
12-Amethyst

How to highlight or change the background color of an attribute using datautility?

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?

4 REPLIES 4
HelesicPetr
22-Sapphire I
(To:spitchan)

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.

HelesicPetr
22-Sapphire I
(To:spitchan)

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

 

 

HelesicPetr
22-Sapphire I
(To:spitchan)

Hi @spitchan 

Just example how the css works in my test system

defined css style in Windchill\codebase\netmarkets\css\windchill-base.css

HelesicPetr_0-1646905193391.png

 

set in DataUtility as AV-GREEN 

HelesicPetr_1-1646905258070.png

result in the Windchill

HelesicPetr_2-1646905308016.png

 

Best Regards

 

PetrH

 

 

 

Top Tags