on 12-04-2007 5:30 PM
Hi all,
I want to display my table cells in different colors based on the value I get from my BAPI.I have just one column in the table which I m trying to set colors. The model attribute is returning values RED,GREEN and GREY.
My view context:
Z_BAPI_M
---Output
-
Material_View_Res (Model Node)
-
Accounting(model attribute)
cellcolor(value node)
-
cellDesign1(value attribute)
int nodeSize = wdContext.nodeMaterial_View_Res().size();
IPrivateTitleMaintenanceView.IMaterial_View_ResNode materialViewRes =
wdContext.nodeMaterial_View_Res();
IPrivateTitleMaintenanceView
.IMaterial_View_ResElement materialViewResElement;
for (int i = 0; i < nodeSize; i++) {
wdComponentAPI.getMessageManager().reportSuccess(
"inside loop " + i);
Zmmweb_St_Material_View materialView =
new Zmmweb_St_Material_View();
materialViewResElement =
materialViewRes.createMaterial_View_ResElement(materialView);
materialViewRes.addElement(materialViewResElement);
wdComponentAPI.getMessageManager().reportSuccess(
"create element and add " + i);
String strStatus =
wdContext.nodeMaterial_View_Res().getElementAt(
i).getAttributeAsText(
"Accounting");
wdComponentAPI.getMessageManager().reportSuccess(
"Accounting " + strStatus);
// if (strStatus.equalsIgnoreCase("GREY")) {
// wdComponentAPI.getMessageManager().reportSuccess(
// "Accounting color inside first if condition" + strStatus);
// wdContext.currentContextElement().setCellDesign1(WDTableCellDesign.STANDARD);
// }
if (strStatus.equalsIgnoreCase("RED")) {
wdComponentAPI.getMessageManager().reportSuccess(
"Accounting color inside second if condition" + strStatus);
IPrivateTitleMaintenanceView.ICellcolorElement cellColorElement = wdContext.nodeCellcolor().createCellcolorElement();
IPrivateTitleMaintenanceView.ICellcolorNode cellColorNode = wdContext.nodeCellcolor();
cellColorNode.addElement(cellColorElement);
cellColorElement.setCellDesign1(WDTableCellDesign.NEGATIVE);
// wdContext.nodeCellcolor().getElementAt(i);
wdComponentAPI.getMessageManager().reportSuccess(
"get each cellcolor element");
//wdContext.current
}
}
The problem is I am not able to set each cell based on the values from backend. Its getting set either Red or Grey or Green.
Please tell me where I went wrong?
Thanks
Anjana
Hi Anjana,
You have to create a context attribute of com.sap.ide.webdynpro.uielementdefinitions.TextViewSemanticColor with properties <b>calculated</b> and <b>read only</b> true.Set the WDTableCellDesign property of the table to In the getattribute method return values of type TextViewSemanticColor .X (positive for green, negative for Red and exactly Grey iss not possible some other colour need to be set) depending on condition(strStatus.equalsIgnoreCase("X"))
regards,
Siva
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Siva,
I have made my context value attribute cellDesign1 to com.sap.ide.webdynpro.uielementdefinitions.TextViewSemanticColor .set calculated to true. If i set read only to true, I wont be able to set the value.So I left it false.
The second line in ur post is not clear. What should I set the wdtablecelldesign property to. I have set it to cellDesign1. and based on the condition I am setting
cellColorElement.setCellDesign1(WDTextViewSemanticColor.NEGATIVE);//for Red
But its not giving any colors now.
Am I missing something?
Thanks
Anjana.
Sorry,
I just missed something. I make it clear here. Set read only true. Since this is a calculated attribute a method getcellDesign1() of return type TextViewSemanticColor is created. In this method write th following
if (strStatus.equalsIgnoreCase("RED")) {
return WDTextViewSemanticColor.NEGATIVE;
}
else if (strStatus.equalsIgnoreCase("GREEN")) {
return WDTextViewSemanticColor.POSITIVE;
}
else
return WDTextViewSemanticColor.STANDARD;
Set this context attribute cellDesign1 to semanticColor property of your textView in the table
Regards,
Siva
Hi Siva,
In my View init() I am calling my BAPI.
my context :
cellColor(value node)
---cellDesign1(value attribute)
Now I have made the cell design1 to com.sap.ide.webdynpro.uielementdefinitions.TextViewSemanticColor.
and made my layout textview semanticColor property to cellDesign1.
I got the new method getcellColorDesign1(IPrivateTitleMaintenanceView.ICellcolorElement element){
int nodeSize = wdContext.nodeMaterial_View_Res().size();
IPrivateTitleMaintenanceView.IMaterial_View_ResNode materialViewRes =
wdContext.nodeMaterial_View_Res();
IPrivateTitleMaintenanceView
.IMaterial_View_ResElement materialViewResElement;
for (int i = 0; i < nodeSize; i++) {
String strStatus =
wdContext.nodeMaterial_View_Res().getElementAt(
i).getAttributeAsText(
"Accounting");
if (strStatus.equalsIgnoreCase("RED")) {
return WDTextViewSemanticColor.NEGATIVE;
} else if (strStatus.equalsIgnoreCase("GREEN")) {
return WDTextViewSemanticColor.POSITIVE;
} else
return WDTextViewSemanticColor.STANDARD;
}
return null;
}
I am not getting the color set in my cell.Where did I went wrong?Is my loop correct?
Thanks
Anjana
Hi Anjana,
Put cellcolor node in Material_View_Res node
cellcolor node properties <i>singleton false</i> cardinality 1..1
//try with current element if not possible then use get ith element
String strStatus =
wdContext.nodeMaterial_View_Res().currentMaterial_View_ResElement(
i).getAttributeAsText(
"Accounting");
if (strStatus.equalsIgnoreCase("RED")) {
return WDTextViewSemanticColor.NEGATIVE;
} else if (strStatus.equalsIgnoreCase("GREEN")) {
return WDTextViewSemanticColor.POSITIVE;
} else
return WDTextViewSemanticColor.STANDARD;
}
Just remove <b>return null</b>; in last line
regards,
Siva
Edited
Message was edited by:
Raja Thangamani
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.