cancel
Showing results for 
Search instead for 
Did you mean: 

how to replace variant to the column name to set value?

Former Member
0 Kudos

e.g.:i have many columns in my table.now i need to control of the visual attribute.now i hope iterator the columns to set visual value.

for example:i have a node testNode and a value attribute named testValue of it.i bind it to the some context.

now i hope used such code to operate it:

<b>String x="testValue";

wdContext.currentTestNodeElement.setx(WDVisibility.VISIBLE);</b>

you know it cann't run.who can give me some advices on it.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Wingoal,

Bind the separate arrtibute value (eg)TestVisible to bind the visibility with the type com.sap.ide.webdynpro.uielementdefinitions.Visibility.

wdContext.currentTestNodeElement.setTestVisible(WDVisibility.VISIBLE);

Kind Regards

Mukesh

Former Member
0 Kudos

hi.Mukesh mani

i just done as u said.bind a attribute value to the visibility of some column in table.

but i need to set the visiblility attribute dynamically for the every column in table and i don't wanna judget it for every column in such way(repeat N times:

<b>if(x=1){

wdContext.currentTestNodeElement.setx(WDVisibility.VISIBLE);

}else{

wdContext.currentTestNodeElement.setx(WDVisibility.NONE);

}</b>

follow is my best ideal:

ArrayList list=getMethold();//select the need to set WDVisibility.VISIBLE columns,it have the same name as bind context var.

for(int i=0;i<list.size();i++){

String temp=(String)list.get(i);

wdContext.currentTestNodeElement.settemp(WDVisibility.VISIBLE);

}

Former Member
0 Kudos

Hi Wingoal,

Try This

IPrivate<ViewName>.I<Name>Node node = wdContext.node<Name>();

node.invalidate();

ArrayList list=getMethold();

for(int l=0;l<list.size;l++) {

IPrivate<ViewName>.I<Name>Element element = wdContext.create<Name>Element();

element.set<Param>(WdWisi);

String temp=(String)list.get(i);

int x=Integer.parseInt(temp);

if(x=1){

wdContext.currentTestNodeElement.setx(WDVisibility.VISIBLE);

}else{

wdContext.currentTestNodeElement.setx(WDVisibility.NONE);

}

//do Add other parameter

node.addElement(element);

}

Kind Regards

Mukesh

Former Member
0 Kudos

Create a value node called "ColumnVisibility" ( <b>with cardinality 1:1 </b>) under the root context.

Create as many value attributes ( datatype: ddic:com.sap.ide.webdynpro.uielementdefinitions.Visibility ) as the number of columns in your table and bind them to the visibility property of the appropriate columns.

(For example: The attributes ColumnOneVisibility, ColumnTwoVisibility, ColumnThreeVisibility are bound to column1, column2, column3).

Now use this code to control the visibility of columns


String[] attributeNames = {"ColumnOneVisibility", "ColumnThreeVisibility","ColumnTwoVisibility"};
    
    for(int k = 0; k < attributeNames.length; k++)
    {
    	IWDNodeElement columnVisibilityElement = 
(IWDNodeElement)wdContext.currentColumnVisibilityElement();
    	/** Use your condition here */
    	/** and set WDVisibility to VISIBLE or NONE depending upon the requirement*/ 
columnVisibilityElement.setAttributeValue(attributeNames[k],(WDVisibility) WDVisibility.NONE);
		
    }

Bala

Message was edited by: Bala Krishnan

Former Member
0 Kudos

@Bala

Your code was probably correct, but the forum software corrupted it (that's why I always use "j" as index variable and not "i").

The correct code should be:


String[] attributeNames = {"ColumnOneVisibility", "ColumnTwoVisibility","ColumnThreeVisibility"};
    
for (int j = 0; j < attributeNames.length; j++)
{
  IWDNodeElement columnVisibilityElement = wdContext.currentColumnVisibilityElement();
  boolean columnVisible = ...;
  columnVisibilityElement.setAttributeValue
  (
    attributeNames[j],
    columnVisible ? WDVisibility.VISIBLE :  WDVisibility.NONE
  );
}

Armin

Former Member
0 Kudos

Yes Armin. You are right. I just copied and pasted the code from a working sample. Thanks for pointing out that and in future,while posting code, I'll follow the index variable naming convention you've prescribed ;-).

Bala

Answers (0)