on 12-28-2007 9:29 AM
Hi,
I have a list of 5 names to be put into 3 dropdownbykey boxes..
Now what I want is once a name gets seletced in one of the three dropdown, it should not appear in other two dropdowns.
For example, 5 names are :- Amey, Mike, John, Bryan, Sam.
Then if 'Mike' is selected in one of the dropdowns, it should not appear in rest two dropdowns..
If anybody has done this kinda thing of came across it, then pls let me know as soon as possible !
Hi,
For this you need use 3 different nodes. Populate initially all these with all 5 values.
Create 3 actions and bind them to the property of onActionSelect() of the dropDownBoxes.
In dropdown1 action
do like this:
//code sample
//delete the dropdown1 selected value from dropdown2
IPrivate<View>.I<node2>Element el;
for (int i = 0; i < wdContext.<node2>().size(); i++)
{
el=wdContext.<node2>().get<node2>()ElementAt(i);
// compare with value selected in dropDown1
if(el.get<attributename>().equalsIgnoreCase(wdContext.<node1>().current<node1>()Element()))
{
wdContext.<node2>().removeElement(el);
}
}
//end of code sample
repeat this //code sample for node3.
//END OF ACTION1
In dropdown2 action
repeat this //code sample for node1.
repeat this //code sample for node3.
In dropdown3 action
repeat this //code sample for node1.
repeat this //code sample for node2.
regards,
Siva
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Why do you need to use DropDownByKey? You might also use 3 DropDownByIndex UI elements bound to 3 context nodes with 3 supply functions.
Add to each drop-down list an action. In the action handler, call invalidate() for each of the other context nodes. Example:
void onAction<Node1>Selected()
{
wdContext.node<Node2>().invalidate();
wdContext.node<Node3>().invalidate();
}
The supply function for e.g. the second node will look like this:
void supply<Node2>(I<Node2> node, ...)
{
I<Node1>Element selection1 = wdContext.current<Node1>Element();
I<Node3>Element selection3 = wdContext.current<Node3>Element();
for (int i = 0; i < NAMES.length; ++i)
{
if ( selection1 != null && NAMES<i>.equals(selection1.getName()) ) continue;
if ( selection3 != null && NAMES<i>.equals(selection3.getName()) ) continue;
I<Node2>Element e = node.createAndAdd<Node2>Element();
e.setName(NAMES<i>);
}
}
//@@begin others
static final String[] NAMES = { "Amey", "Mike", "John", "Bryan", "Sam" };
//@@end
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Armin,
But tell me one thing, I want to retain the value which i selected in 1st dropdown.
If we call invalidate for other nodes, then wont i lose value which i selected in 1st dropdown?
That is, when i move on to 2nd dropdown, the selection which i made in 1st dropdown should not change. Will above method ensure this?
Do u get what i mean?
Pls let me know what u think..
regards,
Amey
Dear Amey,
IWDAttributeInfo attributeInfo =
wdContext.getNodeInfo().getAttribute("DropDownFieldContextName");
// DropDownFieldContextName is a context attribute ( could be of string type also) that is bound to the dropdown box at design time.
ISimpleTypeModifiable objType = attributeInfo.getModifiableSimpleType();
IModifiableSimpleValueSet valueSet =
objType.getSVServices().getModifiableSimpleValueSet();
// valueSet.put("key","value");
valueSet.removeKey("key"); // Enter key to remove in double qoutes
Write this code in the onselect function of the first dropdown
You can get the key to delete from context attribute bound to first dropdown.
Tell me if you want more information.
Regards,
Mayuresh
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Edited by: Armin Reichert on Dec 28, 2007 12:46 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Populate the first drop down when the screen is initialized
Try to populate the other drop downs from the onSelect event of the first Dropdown by key.
OR
Populate all the drop down when the screen is initialized
OnSelect try to remove it from others.
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.