cancel
Showing results for 
Search instead for 
Did you mean: 

Set Negative values in red color

Former Member
0 Kudos

Hi, i want to set the negative values in the table in the red color.I have created the table dynamically.So i have created a context node called "ColorData" and in that i created a context attribute "grossSemantic". I have set the type of this attribute as "com.sap.ide.webdynpro.uielementdefinitions.TextViewSemanticColor" .And i have written the below code.

But there is no effect at all. Where am i going wrong? Please suggest.

String color = "ColorData";

IPrivate<ViewName>.IColorDataNode colorNode = wdContext.nodeColorData();

IPrivate<ViewName>.IColorDataElement colorElem = colorNode.createColorDataElement();

for(int flag = 0; flag < wdContext.node<BapiNodeName>.size(); flag++){

IPrivate<ViewName>.I<BapiNodeElement> tableElem = bapiNode.get<BapiElement>(flag);

if(tableElem.get<ColumnName()>.signum() == -1){

editor.bindDesign(color "." "grossSemantic");

colorElem.setGrossSemantic(WDTextViewSemanticColor.NEGATIVE);

column.setTableCellEditor(editor);

}

}

Regards,

Padmalatha.K

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Say the table data source is named "Rows".

Add a calculated context attribute "color" of type TextViewSemanticColor to node "Rows" (or an 1:1 subnode if needed).

Bind the table cell editor (TextView) property "semanticColor" to attribute "color".

Implement calculated attribute as


WDTextViewSemanticColor getRowsColor(..., IRowsElement element)
{
  return element.getSign() == -1 : WDTextViewSemanticColor.NEGATIVE : WDTextViewSemanticColor.STANDARD;  
}

Armin

Former Member
0 Kudos
WDTextViewSemanticColor getRowsColor(..., IRowsElement element)
{
  return element.getSign() == -1 ? WDTextViewSemanticColor.NEGATIVE : WDTextViewSemanticColor.STANDARD;  
}

(Fixed typo with ternary operator )

Former Member
0 Kudos

Hi,

Thanq for the reply but i cannot create a context attribute in the node which is bound as the data source to the table as im directly binding the model node to the data source of the table.

Is there any other way of doing it?

Please suggest as im unable to proceed further.

Regards,

Padmalatha.K

Former Member
0 Kudos

Hi,

Did you try to create a node with cardinality 1..1 under this node and create an attribute?

Regards

Ayyapparaj

Former Member
0 Kudos

Hi Ayyaparaj,

Thanq for the reply.

I created a node with cardinality 1:1 and in the node i created an attribute of the type "TextViewSemanticColor" and set the "Calculated" property of this attribute as true.

But in the getter method, when i try to add the code

return element.getSign() == -1 ? WDTextViewSemanticColor.NEGATIVE : WDTextViewSemanticColor.STANDARD; } (Fixed typo with ternary operator )

Im not getting the method "element.getSign()"

And where do i need to call this method?

Please suggest.

Regards,

Padmalatha.K

nikhil_bose
Active Contributor
0 Kudos

replace

element.getSign() ==  -1 

with

element.signum() == -1

nikhiL

Former Member
0 Kudos

Hi

Even getSignum() is not available.

Please suggest.

Regards,

Padmalatha.K

Former Member
0 Kudos

Hi,

Give a try

element.node().getCurrentElement().getSign()

Regards

Ayyapparaj

Former Member
0 Kudos

Hi

Even

element.node().getCurrentElement().getSign()

is not available.

Regards,

Padmalatha.K

Former Member
0 Kudos

Hi,

Can you post your context structure?

Regards

Ayyapparaj

nikhil_bose
Active Contributor
0 Kudos

IPrivate<ViewName>.I<BapiNodeElement> elm;
    elm = (IPrivate<ViewName>.I<BapiNodeElement>)
    element.node().getParentElement();
    
    return elm.getSignnum() == -1: WDTextViewSemanticColor.NEGATIVE : WDTextViewSemanticColor.STANDARD;;

nikhiL

Former Member
0 Kudos

Context

>> Bapi - (Node)

>>OutputNode - (Node)

>>DesignData - (Node)

>>ColorData - (Attribute).

In the above context structure, Output node is the table data source. In this node i created a node "DesignData" of cardinality 1: 1 and in this node i created an attribute "ColoData" of type TextViewSemanticColor and set the calculated property as true.

Regards,

Padmalatha.K

nikhil_bose
Active Contributor
0 Kudos

replace BapiNodeElement with IPrivate<ViewName>.I<BapiNodeElement> the element which contains sign

nikhiL

Former Member
0 Kudos

Hi,

Is it mandatory to use only this line of code in the get method?

return element.getSign() == -1 ? WDTextViewSemanticColor.NEGATIVE : WDTextViewSemanticColor.STANDARD; }

Can i not use my own code?

If i can use my own code in the get method, please tell me where and how to call this get method?

Regards,

Padmalatha.K

Edited by: padmalatha kontham on May 20, 2008 10:47 AM

Former Member
0 Kudos

in calculated getter:


IOutputNodeElement parent = (IOutputNodeElement) element.node().getParentElement();
return parent.getSign() == -1 ? WDTextViewSemanticColor.NEGATIVE : WDTextViewSemanticColor.STANDARD;

Set singleton=false and selection=1:1 for node "ColorData".

Armin

Former Member
0 Kudos

Hi Armin,

Is it necessary to write only this line of code in the get method?

Can i not write my own code in the get method?

If i can write, how do i call this method and where do i call this method?

Regards,

Padmalatha.K

Former Member
0 Kudos

Hi,

Is it necessary to write only this line of code in the get method?

No.

Can i not write my own code in the get method?

Yes

If i can write, how do i call this method and where do i call this method?

It will be called by the framework if its bound to a UI element

or if you want to call explicitly call using element.get<AttributeName>()

Regards

Ayyapparaj

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

From your post i can understand that you want to display negative value in red color throughout the table. For this you can use CellVariants. Create two cellvariants and add one textview to each. Give one text view the semantic color for red and for another give the normal one (for black).

In runtime you can choose the cellvariant for a column according to the value for display purpose.

Hope it helps.

thanks & regards,

Manoj