cancel
Showing results for 
Search instead for 
Did you mean: 

how to populate one dropdown on select of other dropdown in a table

0 Kudos

Hi

My requirement is that I want to populate one dropdown on selection of some value in other drop down.The two dropdown are present in two columns of a Table.

Can any body help for the same.

Regards

Nitin

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

If your table source node is 'FirstColumnNode' and the contents of 'FirstColumnNode' is as follows:

FirstColumnNode(0..n)

|_SecondColumnNode(0..n)

And your table's first column (drop down) should be mapped to FirstColumnNode , second column (dropdown) should be mapped to SecondColumnNode.

Now when you select a value from the FirstColumn Node (in dropdown), corresponding current element's SecondColumnNode will be populated in the second column(dropdown).

Just check this and let me know ..No coding needed..

Thank you,

Divya

Former Member
0 Kudos

Hi,

Try This

Bind "enable" properties of Both DD1 and DD2 to

context attributes of type boolean. DD1Enable,DD2Enable

1: set their value to false intially

wdContext.currentContextElement.setDD1Enable(false);

wdContext.currentContextElement.setDD2Enable(false);

Bind the selected property of the table to a

Context attribute of type boolean(Initially false), say "selected"

2: Then use check box in the table to get current lead selection

write in "onToggle" action of checkBox

int len=wdContext.nodeTable().size();

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

{

if(wdContext.currentTableElement().getSelected()==true)

{

wdContext.currentDD1Element().setDD1Enabled(true);

wdContext.currentDD2Element().setDD2Enabled(true);

}else

{

wdContext.currentDD1Element().setCountryEnabled(false);

wdContext.currentDD2Element().setStateEnabled(false);

}

}

This is how u get leadselection and able to change particular row in the table

Regards

Lakshmi

0 Kudos

Hi Lakshmi

Thanks for the reply.But what I exactly need is coding idea for population of the dropdown on select of another dropdown .Both the dropdown are in the table.They form the two columns of the table. Also the population should happen within the row.

eg if i select A Column(Dropdown A) in row 1 then it should populate column B(Dropdown B) in row 1

Former Member
0 Kudos
Context:

Rows (node)
-- ItemsA (node, singleton=false)
---- text (string)
-- ItemsB (node, singleton=false)
---- text(string)

DropDownByIndex editorA;
editorA.texts -> Rows.ItemsA.text
editorA.onSelect -> ItemASelected (action)
editorA.mappingOfOnSelect: nodeElement -> row : IRowsElement (action parameter)

DropDownByIndex editorB;
editorB.texts -> Rows.ItemsB.text

Action handler:

onActionItemASelected(..., IRowsElement row)
{
  IItemsAElement selectedItemA = row.nodeItemsA().currentItemsAElement();
  row.nodeItemsB().invalidate();
  {
    IItemsBElement item = row.nodeItemsB().createAndAddItemsBElement();
    item.setText("Item #1 in dropdown B");
  }
  {
    IItemsBElement item = row.nodeItemsB().createAndAddItemsBElement();
    item.setText("Item #2 in dropdown B");
  }
  /* etc */
}

Armin

Former Member
0 Kudos

Hi Nitin,

make the 2nd attribute as calculated.It will generate the getter & setter method.u can populate the 2nd dropdown in setter method according to the value selected in 1st drop down.

regards

Sumit

Former Member
0 Kudos

Hi,

Assume you need to get the DD2 populated on some value of DD1.

To get the current element of DD1.

wdContext.node<nodename binded to DD1>().current<nodename binded to DD1>Element().get<attributename>();

You can check for the returned value and use it in the if else clause to suffice your need.

To polulate new values in DD2.

IPrivate<viewname>.I<nodename binded to DD2>Element ele = wdContext.node<nodename binded to DD2>().create<nodename binded to DD2>Element();

ele.set<attributename>(<value>);

wdContext.node<nodename binded to DD2>().addElement(ele);

Repeat the above step for the number of elements that you want to add to your DD2.

Warm Regards,

Murtuza

0 Kudos

Hi Murtuza,

Thanks for the reply. my problem is that this should happen in the table.

The senario is that I have a table with two columns.Each columns have dropdown by index.The table has 10 rows. now when I select dropdown(of first column) in a particular row (say 1st row)then I need to populate the drop down(in second column) of the same row(i.e 1st row) ,leaving other rows unaltered

Can u guide me for the same

regards

nitin

Former Member
0 Kudos

Hi,

You might be having both the nodes binded to your drop down within you table node.

Just get the selected row and read the value of the dd1 and set the value of dd2 for the same row.

Rest procedure remains the same. Only you will need to get the currently selected row and based on that update the nodes of the current index.

Warm Regards,

Murtuza

0 Kudos

Hi thanks one again,

the problem is how to update the node of the current index.

I am able to retrive the value and the current index but not getting a way to update the child node(i.e the node for dropdown) for the current index.

can u help me in doing that.

regards

nitin

Former Member
0 Kudos

Hi,

Do

Use the (implicit) event parameter "nodeElement" to identify the row where the action was triggered. Either define a parameter mapping using the view designer tool (Outline view, right-click on InputField -> Parameter Mapping), or with a line of code like

wdDoModifyView(...)

{

if (firstTime)

{

IWDInputField editor = (IWDInputField) view.getElement("inputfield_ID");

editor.mappingOfOnAction().addSourceMapping("nodeElement", "row");

}

}

"row" must be an action parameter of type I<DataSourceNode>Element or IWDNodeElement.

Sorry for the missing url

Regards

Ayyapparaj

Former Member
0 Kudos

Hi,

If table is your main node and you have child node inside this then if you write:

<b>wdContext.nodeChild()</b> then this refers to the node corresponding to the current lead selection of the parent node.

Hence, you will get the child node for the selected row in your table.

Regards,

Murtuza

Former Member
0 Kudos

If you just copy/paste my answer to some other question, you could at least add a link to the original thread, don't you think?

Armin