cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle dropdown boxes for multiple table rows ?

Former Member
0 Kudos

Hi All,

I have got a table in which one column is a dropdown box. The values of the dropdown box are fetched from an RFC. I have made a context in the component controller where I am getting all the values to be displayed inside the dropdown box. The dropdown box is populated using this context using a function in the component controller. After populating the dropdown box I am displaying a default value ( which is again fetched from a RFC ) as the current value. Then I am sending the current value of the dropdown box ( the default value or any other selected value by the end user ) back to another RFC.

Now, this is working fine when the table has only 1 row. Once there are more than 1 rows, I am facing a problem. After selecting the value in the dropdown box of the 1st row, when I click the dropdown box of the second row, the selected value of the box in the first row gets changed to the selected value of the box of the second row. Also if I go back to the 1st row dropdown box and change its value, the value of the dropdown box of the 2nd row gets changed to that of the 1st row dropdown box selected value.

Please provide a solution to this.

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member187990
Participant
0 Kudos

Hi Sayan,

Please check if you have mapped the DropdownBox of the Table to an attribute directly under the context. Place the attribute inside a Node. Only in that case every time a change is made to a particular DropdownBox, does not affect the other DropdownBox values. Every value will act as an Individual Element.

Your situation was an attribute placed right under the root node context, which will hold only one value. (Recently selected value)

Regards,

Satish Kumar SV

Former Member
0 Kudos

Hi Sayan,

Follow this Procedure

1)First Take DropDownByIndex

2)In the ComponentController Create a valuenode(Ex:Emp) create 2 attributes 1)Key 2)Value

3)Write Supply function for the above node in the ComponentController.

a)Select valuenode(Ex:Emp) rightclick properties click on SupplyFunction click ok button

You get supply function method in ComponentController

Fill the node using RFC by following code

punlic void supplyEmp()

{

//IEmpElement obj = null;

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

{

obj = wdcontext.createEmpElement();

obj.setKey("This will come from RFC");

obj.setValue("This will come from RFC");

node.addElement(obj );

}

}

Change node properties

cardinality 0---n

Singleton --false

Selection Mode 1--n

4) Copy the same node view Context, Do Context mapping with ComponentController same node.

5) Bind DropDownByIndex with Emp node of Value.

I guess you get the idea how to do.If you need any clarifficatons buzz me.

Rgds

-SS

Former Member
0 Kudos

Hi,

I have changed the singleton velue of the context node to false and I am now getting different dropdown boxes for individual rows.

There is yet another issue. The context has a supply function by which it is populating the dropdown box. Now when there is only 1 row, the supply function is called once and it is populating the values accordingly. But when there are more than 1 rows, there is a problem. Suppose there are 2 rows. So there will be 2 dropdown boxes and hence the supply function would be called twice for populating each of the dropdown box. Here the function populates the first dropdown box with the values of both the 1st dropdown box and also of the 2nd dropdown box while the 2nd dropdown box is empty. In other words, for 2 rows, the supply function is re-populating the 1st dropdown box with the values of the 2nd dropdown box instead of populating the 2nd dropdown box.

Please advice.

Former Member
0 Kudos

Hi Sayan,

I am giving proper example to you.

Node Strucure in the ComponentController

EmpTable(ValueNode)

Emp(ValueNode) Properties cardinality (on) SingleTon(False)

-


Name (Value Attribute)

-


name (Value Attribute)

Same Node Structure copied in to the view and mapped with ComponentContoller.

SupplyFunction

public void supplyEmp(IPrivateRnD.IEmpNode node, IPrivateRnD.IEmpTableElement parentElement)

{

//@@begin supplyEmp(IWDNode,IWDNodeElement)

IEmpElement obj = null;

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

{

obj = wdContext.createEmpElement();

obj.setName("AAA");

obj.setNumber("1111");

node.addElement(obj);

}

init() method of ComponentController

IEmpTableElement obj = null;

try {

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

{

obj = wdContext.createEmpTableElement();

wdContext.nodeEmpTable().addElement(obj);

}

} catch (Exception e1) {

e1.printStackTrace();

}

Understand the above code, Develop accroding to your requirement.

Difference is you have create the node structure in the RFC output table.

If you get any doubts buzz me.

Rgds

-SS

Former Member
0 Kudos

Post the code of the supply function. Probably you are filling the wrong node there.

Armin

Former Member
0 Kudos

Hi,

Suppose I am using the following context structure in component controller.

node Parent (parent node)

- node Child (child node) cardinality (on) SingleTon(False)

-


attribute name (string)

The structure binding between the component controller and view is done.

Now in the table there are many rows, and each row has a dropdown box. So for n rows there are n dropdownboxes. Suppose there are 3 values to be populated in each dropdown box and let the supply function for populating Child node be supplyChildfunction().

so the coding for supply function should be like :

public void supplyChild()

{

IChildElement objChild=null;

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

{

objChild= wdContext.createChildElement();

wdContext.nodeChild().addElement(objChild);

}

}

Now if there are n no. of rows in the table then, I am creating 1 parent node object for each row. So for n rows there should be n parent node objects.

But I cannot fetch the value of n in the init method of the component controller. The value of n is actually the value of a node size ( fetched from RFC ) and this can be obtained only in a perticular view.

Hence I am using a coding in view to create Parent node objects in the component controller. Please notice that supply function is in component controller.

Here is the code which I am using in the view.

IParentElement objParent = null;

try {

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

{

objParent = wdThis. wdGetComponentController(). wdGetContext(). createParentElement() ;

wdThis. wdGetComponentController(). wdGetContext(). nodeParent(). addElement(objParent) ;

}

}

catch (Exception e1) {

e1.printStackTrace();

}

Now I am used this code, for makeing objects of the Parent node ,in the init() method of view. But it was populating the value only for the dropdown box of the 1st row and that too only once. The other dropdown boxes were all empty.

Then I tried again by using the above code in wdModify() method but it also gave the same error.

Please suggest where am I going wrong....

regards,

Sayan

Former Member
0 Kudos

I don't believe that the given method really is the supply function. A supply function has a parameter denoting the parent element of the node to be supplied. And this is crucial here: You have to add the dropdown entries into the child node for the given parent element, like

IParentElement parent = ...;
IChildElement child = parent.nodeChild().createChildElement();
parent.nodeChild().addElement(child);

Armin

Former Member
0 Kudos

Hi Armin,

It is a supply function only. Its just that I did not provide the parameters to make it short.

The supply function is of type

public void supplyChild( IPrivateComponent.IChildNode node, IPrivateComponent.IParentElement parentElement)

{ ......

......

}

Regards,

Sayan

Former Member
0 Kudos

Replace

wdContext.nodeChild().addElement(objChild);

by

parentElement.nodeChild().addElement(objChild)

Armin

Former Member
0 Kudos

Hi,

Let me just tell you how this should be done, since I don't know the context structure that you have used.

The context structure should be like this:

Rows (cardinality 0:N)

--Items (cardinality 0:N, selection 0:1, singleton=false)

-


Text: string

Data binding:

Table.dataSource -> Rows

TableColumn.TableCellEditor(DropDownByIndex).texts -> Text

So check the cardinality and also the singleton property of the Items node (in the example, but in your case this will be different).

Regards,

Satyajit.

Former Member
0 Kudos

Hi,

I have changed the singleton velue of the context node to false and I am now getting different dropdown boxes for individual rows.

There is yet another issue. The context has a supply function by which it is populating the dropdown box. Now when there is only 1 row, the supply function is called once and it is populating the values accordingly. But when there are more than 1 rows, there is a problem. Suppose there are 2 rows. So there will be 2 dropdown boxes and hence the supply function would be called twice for populating each of the dropdown box. Here the function populates the first dropdown box with the values of both the 1st dropdown box and also of the 2nd dropdown box while the 2nd dropdown box is empty. In other words, for 2 rows, the supply function is re-populating the 1st dropdown box with the values of the 2nd dropdown box instead of populating the 2nd dropdown box.

Please advice.