cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding dropdownindex

Former Member
0 Kudos

Dear Frds

I have two drop down index

which has same values 1,2,3,4,5 etc

When i select 1 in one dropdown index that 1 should not appear in another drop down index i mean drop down index values are 2,3,4,5

Sinilarily when i select 2 in one drop down index the other

drop down index values are 1,3,4,5....

i need to delete the corresponding selected in one drop down index,... or dynamically generate the second drop down index based on the values of first one...

Thanks and Regards

Shravan

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Context:

List1 (node, 0:n)

- text

List2 (node, 0:n, supply function = supplyList2)

- text

DDByIndex1.texts = List1.text

DDByIndex2.texts = List2.text

Assign an action "List1Selected" to DDByIndex1 and implement action handler as


wdContext.nodeList2().invalidate();

Implement supply function for node List2 as


void supplyList2(...node...)
{
  int selection1 = wdContext.nodeList1.getLeadSelection();
  for (int i = 0; i < wdContext.nodeList1.size(); ++i)
  {
    if (i != selection1)
    {
      IList2Element e = node.createList2Element();
      node.addElement(e);
      e.setText(wdContext.nodeList1().getList1ElementAt(i).getText());
    }
  }
}

Armin

Former Member
0 Kudos

Hello Shravan,

Adding the records in second drop down is a good way. Alternatively, You can also delete the record which is not required from the second drop down.

Say the you have a context node SecondNode and a value attribute as SecondDrpDownValue, and this mapped to drop down by index.

You can remove using a logic similar to the one below

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

ISecondNodeElement drpDownElement = wdContext.nodeSecondNode().getSecondNodeElementAt(i);

int value = drpDownElement.getSecondDrpDownValue();

// instead of 2, insert your variable having the value

//to be removed.

if(value == 2){

wdContext.nodeSecondNode().removeElement(drpDownElement);

}

}

Thanks.

Former Member
0 Kudos

Hello Shravan,

Adding the records in second drop down is a good way. Alternatively. You can also delete the record which is not required from the second drop down.

Say the you have a context node SecondNode and a value attribute as SecondDrpDownValue, and this maped to drop down by index.

You can remove using a logic similar to the one below

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

ISecondNodeElement drpDownElement = wdContext.nodeSecondNode().getSecondNodeElementAt(i);

int value = drpDownElement.getSecondDrpDownValue();

if(value == 2){

wdContext.nodeSecondNode().removeElement(drpDownElement);

}

}

Former Member
0 Kudos

Hi ,

1) Save the Selected Value to a variable.

String selValue = wdContext.node();

2)loop through the node and add the values to second drop down if the node value is not equal to selected value.

IWDAttributeInfo attributeInfo = wdContext.getNodeInfo().getAttribute("<dropdown2 node>”);
		ISimpleTypeModifiable simpleType = attributeInfo.getModifiableSimpleType();
		IModifiableSimpleValueSet valueSet = simpleType.getSVServices().getModifiableSimpleValueSet();
		
	for (int i=0; i<wdContext.node< node1>().size(); i++)
		{
                    wdContext.node< node1>.setLeadSelect(i);
           String value = wdContext.node< node1>.get< value>();
		if (value != selValue)
			{
				valueSet.put(i, value);
			}  

Regards,

Sunitha

snehal_kendre
Active Contributor
0 Kudos

Hi Shravan,

Keep your 1st dropdown fixed .. and dynamically assign values to 2nd dropdown.

1. Create a value node say ctx_vn_dropdown

2. in value node create an value attribute say ctx_va_index of type string

3. create an string array say index to store values

3. on leadselection of your first dropdown insert values into index array as you need.

i.e. when you select 1 add 2 to 5 values into index

and then simply add data into 2nd dropdown it as you wish

create an element of ctx_vn_dropdown.

add values into ctx_va_index of new element.

add this element into ctx_vn_dropdown.

	IPrivate+your+View.ICtx_vn_dropdownElement l_dropdownnodeElement = null;
	wdContext.nodeCtx_vn_dropdown().invalidate();

//as your 2nd dropdown is going to have values from 1 to 5  //loop it upto 5
	for(int i=0;i<5;i++)
	{
		l_dropdownnodeElement = wdContext.createCtx_vn_dropdownElement();

// add data from *index array* to your 2nd dropdown context.
		l_dropdonnodeElement.setCtx_va_index(index.get(i).toString());
		wdContext.nodeCtx_vn_dropd0wn().addElement(l_dropdownnodeElement);
	}
	
	//set lead selection to -1
	wdContext.nodeCtx_vn_dropdown().setLeadSelection(-1);