cancel
Showing results for 
Search instead for 
Did you mean: 

DropDownListByKey for node and childnode.

Former Member
0 Kudos

Hello all,

I have a problem with DropDownListbykey for node and childnode.

The scenario is the following:

Context

-- NodeA

-


NodeB

-


IdB

-


NameB

-


IdA

-


NameA

I want to show the content of NodeA on dropdownlistbykey ddlA, and the content of NodeB on ddlB. When the user change the selected item of list ddlA, the ddlB has to change.

I use ISimpleTypeModifiable and IModifiableSimpleValueSet to create dinamically

the items for ddlB.

Actually, the child ddlB show only child of the first item of NodeA.

Has someone already implements a scenario like that ?

Thanks in advance.

MAX

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Here is a working example using DropDownByIndex and a supply function for (singleton) subnode.

Context:

Nations (node, cardinality=0:N, selection=0:1)
-- Name (attribute, string)
-- Players (node, cardinality=0:N, selection=0:1, singleton, supply function = buildTeam)
---- Name (attribute, string)

Code in wdDoInit():

for (int j = 0; j < NATIONS.length; ++j)
{
  INationsElement nation = wdContext.createAndAddNationsElement();
  nation.setName(NATIONS[j]);
}

Code for supply function:

public void buildTeam(IPrivateDependentDDView.IPlayersNode node, IPrivateDependentDDView.INationsElement parentElement)
{
  //@@begin buildTeam(IWDNode,IWDNodeElement)
  buildTeam(node, parentElement.index());
  //@@end
}

Code in section @@others:

private static final String[] NATIONS = {"Germany", "France", "Italy"};
private static final String[][] PLAYERS = {{"Lehmann", "Lahm", "..."},{"Barthez", "Sagnol", "..."},{"Buffon", "Nesta", "..."}};

private void buildTeam(IPrivateDependentDDView.IPlayersNode team, int teamIndex)
{
  for (int j = 0; i < PLAYERS[teamIndex].length; ++j)
  {
    IPlayersElement player = team.createAndAddPlayersElement();
    player.setName(PLAYERS[teamIndex][j]);
  }
}

Armin

Answers (4)

Answers (4)

Former Member
0 Kudos

Thanks for the reply.

What I mean is, in the NodeA there are parent value of NodeB. When I select a value from the ddlA I want that ddlB shows only child values of NodeA element selected.

I use DDLbyKey with SVService for create simple type a runtime.

When I start the dynpro, ddlA show the first element of NodeA and ddlB show me the children of this element, correctly.

When I select an element on ddlA, nothing change on ddlB (even if I recreate the simpletype associated).

Maybe some bind operation is missing ?

MAX

Former Member
0 Kudos

Have you assigned some (may be empty) action to the "onSelect" event of ddlA? Without that, no update of B is possible.

Armin

Former Member
0 Kudos

Hi

According to your post some action binding is missed. Create one action like(RefereshAction). Then using the following code. Bind action into DropdownList.

IWDAction ss =wdThis.wdGetRefereshAction();

dropDownList.setOnSelect(ss);

Kind Regards,

S.Saravanan.

Former Member
0 Kudos

Hi,

Create one Node using the following code. Inside the DoInit() method

Step 1:

IWDNodeInfo multiplenode = multipleinfo.addChild("MultiNode" , null, true, false, true, true, false, true, null, null, null);

multiplenode.addAttribute("roles", "ddic:com.sap.dictionary.string");

Step 2:

Assign values for Dropdown

IWDNode node1 = wdContext.nodeNodeA().getChildNode("MultiNode", IWDNode.NO_SELECTION);

IWDNodeElement elem1;

for(int s=0;s<5;s++){

elem1 = node1.createElement();

elem1.setAttributeValue("roles","Value"+s);

node1.addElement(elem1);

}

Step 3:

Inside Domodifyview create IWDDropDownByIndex UI Element and Bind it.

IWDDropDownByIndex dropDownList = (IWDDropDownByIndex)view.createElement(IWDDropDownByIndex.class, "drop");

IWDAttributeInfo info = wdContext.getNodeInfo().getChild("NodeA").getChild("MultiNode").getAttribute("roles");

dropDownList.bindTexts(info);

dropDownList.setWidth("100");

Finally add this Dropdown into container. Like this you can create more Dropdown and add action to the dropdown as dynamically.

Kind Regards,

S.Saravanan.

Former Member
0 Kudos

If you want to display attributes of the node elements of NodeA and NodeB in the drop-down lists, use DropDownBy<b>Index</b>.

Armin

Message was edited by: Armin Reichert

Former Member
0 Kudos

Hi MAX,

Could you explaine in more details.

Kind Regards,

S.Saravanan.