cancel
Showing results for 
Search instead for 
Did you mean: 

how to make new column in table changing depending on other columns

Former Member
0 Kudos

hi

i have table and i want to add new column that calculate the deference between two other columns.

i create the column and i could loop in the content of the table but i could not update the entries in the new columns.

regards

Said

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hai Mohammed,

You just create a table with coloumns a,b and c(a-b).In the component controller context for 'c' you set the property calculated as true,then you will get two methods getter and setter.In the getter method you just return the difference like this.

public int getdiff()

{

return(obj.getA()-obj.getB());

}

you will get the result.

Regards

Sathish

Former Member
0 Kudos

Hi ,

One more imp addition , make the variable "c" as read-Only.

- Bharathwaj

Former Member
0 Kudos

Hi!

did u try creating a node for the same? create a value node for the table with 3 value attrbutes, one for each column. then in the init method of that view, just create 3 arrays, setting the value in the first two array. then make use of this code for setting the difference in the thrid column

IPrivateUIView.I<valuenode> tab_node = wdContext.node<valuenode>();

for(int i= 0; i<6;i++)

{

IPrivate<view>.I<valueelement> num_ele = tab_node.create<valueelement>();

num_ele.set<valueattribute1>(num1<i>);

num_ele.set<valueattribute2>(num2<i>);

num_ele.set<diffvalueattribute>(num1<i>-num2<i>);

wdContext.node<valuenode>().addElement(num_ele);

}

this will surely work .

Do let me know the results.

Former Member
0 Kudos

Hai,

Create a table with coloumns bind the datanode--Data(a,b,diff attributes).

ArrayList al =new ArrayList();
for(int i=0;i<wdContext.nodeData().size();i++){
IprivateXXView.IdataElement ele=wdContext.createDataElement();
ele.setA(wdContext.nodeData().getDataElement(i).getA());
ele.setB(wdContext.nodeData().getDataElement(i).getB());
ele.setDiff(wdContext.nodeData().getDataElement(i).getB()-wdContext.nodeData().getDataElement(i).getA());
al.add(ele);
}
wdContext.nodeData().bind(al);

Regards,

Naga