cancel
Showing results for 
Search instead for 
Did you mean: 

How to add data in a table UI from two different NODE

Former Member
0 Kudos

Hello Experts,

We have a requirement to show data in a table which is coming from different node.

Suppose the table has 10 column ( among them 5 are coming from node A and others are coming from node B)

I tried to add node A as a source of the table, and then add individual context to corresponding column element from node A and node B .

Like:

Table Source-->Node A

Table Column1 element value --> NodeA.context

Table Column1 element value--> NodeB.context.

But in this case the problem is, whenever i am trying to add a new row in the table it is copying previous value to the new cell.

I have also tried to add context of B node to A node and then tried to copy data from B node to Anode, but it is saying that Node A is already binded; add or bind element is not possible.

Can any one please help me on this scenario.

Regards,

Sambaran Chakraborty

Accepted Solutions (0)

Answers (1)

Answers (1)

Qualiture
Active Contributor
0 Kudos

Why not simply create a new node and populate it with the values of both A and B? That way you're always certain the right values of A and B are in matching records

Former Member
0 Kudos

Hi,

Thakns for your reply.

Node A and Node B are created from two seperate model Node.

Now can you please explain how can i populate values from Node A and Node B to a NEW NODE.

Regards,

Sambaran

Qualiture
Active Contributor
0 Kudos

Hi,

  • At designtime, create a new node C with the appropriate attributes

  • in your code, iterate through the elements of node A and B (so the values of A are aligned with the proper values of B)

  • within the loop, create and add a new element for node C

  • set the node C attributes with the appropriate node A and node B values

Have a look at the IWDNode and IWDNodeElement API's for more info on the iterateElements(), createAndAdd<yourNode>Element() and get/set attributevalue methods.

Robin van het Hof

Former Member
0 Kudos

Hi,

You can populate values from node A to node B by iteratiing over the values of node A and adding it to node B.

Eg If my view name is TestApp9View and I am having node A and under it I am having two attributes, say name and age , then inorder to copy it to node B, do the following:

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

//Moving the pointer of node A based upon value of i.

wdContext.nodeNodeA().moveTo(i);

//Creating an element for node B

IPrivateTestApp9View.INodeBElement element1 = wdContext.nodeNodeB().createNodeBElement();

//Setting the attributes values of node B from node A

element1.setName(wdContext.currentNodeAElement().getName());

element1.setAge(wdContext.currentNodeAElement().getAge());

//Finally adding that element on to the node B.

wdContext.nodeNodeB().addElement(element1);

}

Hope this helps you.

Regards,

Jithin

Former Member
0 Kudos

Hi,

I tried that option; but for that i get below error..

"cannot bind or add element, because it is already bound to a node "

I my case Node B already have some data.. now when i am trying to add data from node A to node B getting the error.

Regards,

Sambaran

Former Member
0 Kudos

Can i do in this way.,create a node C, then use your method to copy data from both node A and node B to the new node C.

Is it possible to copy attributes of two different node into a single node ?

Qualiture
Active Contributor
0 Kudos

Well, that's what I said, copy from both node A and B to node C.. What don't you understand from this concept?

Let me know,

Robin

Former Member
0 Kudos

Hi,

Yes you can do it. In that case you need to add moveTo() function for both nodeA as well as nodeB inside the for loop. Then only both the node's pointer will move with the value of i.

You can use something lik this:

Create a node C and then do the following: (Considering that name,age,desc,empid are the attributes which we are trying to copy to node C )

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

//Moving the pointer of node A and node B based upon value of i.

wdContext.nodeNodeA().moveTo(i);

wdContext.nodeNodeB().moveTo(i);

//Creating an element for node C.

IPrivateTestApp9View.INodeCElement element1 = wdContext.nodeNodeC().createNodeCElement();

//Copying the attributes values of node C from node A .

element1.setName(wdContext.currentNodeAElement().getName());

element1.setAge(wdContext.currentNodeAElement().getAge());

//Copyingthe attributes values of node C from B.

element1.setDesc(wdContext.currentNodeBElement().getDesc());

element1.setEmpid(wdContext.currentNodeBElement().getEmpid());

//Finally adding that element on to the node C.

wdContext.nodeNodeC().addElement(element1);

}

Regards,

Jithin

Edited by: jithus on Nov 9, 2011 12:44 PM

Former Member
0 Kudos

Hi Robin/Jithin,

I tried that approach. I have copied data from both node A and node B to node C in my component controller.

Then i have binded that node C to a table data source in the View.

Now when i am entering some value in the table fields and calling RFC to populate other data of that table ; its returning data in a seperate row.

That is at the end i have two rows one is for input data and other is for data returned from the RFC.

I think this is occurring because we are using CREATENODEELEMENT in the code.

But if i use CURRENTNODEELEMENT then its returning the error "cannot bind or add element, because it is already bound to a node "

Not sure if i make it clear to you !!!.

Former Member
0 Kudos

Hi,

I didt get you clearly. Why you are merging node A and node B into node C in this scenario? Can you explain what you are trying to acheive?

Regards,

Jithin

Former Member
0 Kudos

Hi,

We have a requirement to show data from different node (coming from different RFC) into a single table.

Now as we can have only one node as Source data for table UI. I am trying to merge two node into single node to use it for the table.

i.e. the table should contain data from two seperate RFC( and moreover one RFC dependent on other; means data entered in one fields of the table call RFC1 and based on the return parameter for RFC1 we are calling RFC2 to populate other fields.

Sambaran

Qualiture
Active Contributor
0 Kudos

Hi,

If you need to

a) populate a table based on values of two sources and

b) also be able to edit the data inline in your table which should result in

c) repopulating your table with both sources,

you might want to revise your design, and create a single RFC which would mimic both RFC's

What you want to achieve in your current situation can be done, but is not easy to develop and may be error prone (i.e. not displaying the proper results)

Former Member
0 Kudos

Hi Sambaran

It seems that your approach is little complex. Because once you have populated the table comprising frm values from two nodes(node A and node B), if you are editing it in table, then repopulating of values from model is needed.

Regards,

Jithin