on 10-05-2011 12:21 PM
There is a table in which i have a drop down.
On select of the drop down I need to populate another drop down in the same of the row of the table.
For this i need to get the element in which the drop down is selected.
Which is not possible inside the OnSelect of the Drop down
Please suggest a way in which I can get the element / any other way that i can find resolution for the above scenario..
Regards
Arjun Nair
Hello,
you can't use the currentElement - that's right.
You have to use parameter mapping.
Add a parameter nodeElement of type IWDNodeElement to the action which is set for the onSelect event and to the corresponding event handler.
Then, in the View Editor, right-click on the DropDownByIndex and select Parameter Mapping from the context menu. Here you can map the parameter nodeElement from the event to the corresponding parameter of your Action by drag and drop.
In the event handler, nodeElement is the element of the row, in which the action was triggered. You have to cast nodeElement to the specific type of your context node to get typed access to the attributes.
Hope this helps,
Bernd
Edited by: Bernd André Stapel on Oct 12, 2011 9:00 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I'm happy that I helped you.
If you have already got the node element which interests you, use it's index() method
If you like to get the index of the selected element in your DropDownByIndex, I think you have to do the same as you have done with the nodeElement. Add a parameter named index to your onSelect action and event handler and do Parameter Mapping to the corresponding parameter of the onSelect event.
Have a nice day
Bernd
Hi Arjun,
I'm not quite sure why you couldn't get the element of the dropdown in the onSelect event... In the event handler, you are perfectly able to get the selected value of the dropdown (and thus the value of the bound attribute in your table context) and based on that value you should be able to populate the second dropdownbykey within the same event handler.
Just be careful, since selecting a different row in your table (which might have a different selected value in the first dropdown) must also repopulate the values of the second dropdown for that row
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Robin,
I think you have not got the scenario properly
It's a dropdownByIndex UI element.
Scenario:
I have a table with 4 elements suppose.
The 2nd element is leadSelected.(currentElement)
Suppose the user clicks on the dropDown if the 3rd element (i.e. not the leadSelect),the OnSlelect event of this particular dropDown is triggered
So,
1.I cannot access the particular dropDown using the currentElement property of the table.
2.Since I cannot access the correct element(i.e. 3rd element)element, I cannnot populate the other dropDown.
1.Please suggest me how to access the 3rd element that is not leadSelected.
2.Can i write multiple Event handler where in I can access from which the event is triggered
Thanks
Arjun Nair
Hi Arjun,
If your table root node is non-singleton, you could use the following in your onSelect event handler:
IDropDownElement yourSelectedDropDownElement = wdContext.currentDropDownElement();
ITableElement tableRowElement = yourSelectedDropDownElement.node().getParentElement();
If your table node is singleton though, I believe it will always return the lead selection...
Sorry Robin
IDropDownElement yourSelectedDropDownElement = wdContext.currentDropDownElement();
ITableElement tableRowElement = yourSelectedDropDownElement.node().getParentElement();
This code is not working in my scenario.
Its getting the value of the dropDown of the that is lead Selected...
But I need the value of the dropDown from where the its selected.
For this I think that i need to know from where is the source of the event.
Regards
Arjun Nair
Hi Arjun,
Context
--Tab_node
-
TableNode
-
attr1
-
attr2
If Tab_node is what represents the table, and TableNode represents the values in the dropdownbyindex element, then Tab_Node should be non-singleton
(Upon selecting the TableNode element from the dropdown, you will need to get the parent Tab_Node, which should be non-singleton)
That's odd... in that case it should work...And according to the API it should work too:
In case of singleton nodes, it is the parent's lead selection element. In case of non-singleton, the node exists once for each element of the parent and this method returns exactly this element
Not sure what else goes wrong here...
Are you able to use a DropDownByKey instead? That way you can always refer to the current element
Thanks Robin,
I m too not sure of the same.
I too read the description that you had sent according which it is correct.
Please look into the code that i have written:
In the <B>View Controller</b>
wdThis.wdGetPrdCrtHQDOCompController().wdThis.wdGetPrdCrtHQDOCompController().function();
In the <B>Component Controller Controller</b>
public void function()
{
IWDNodeElement tableRowElement=null;
if(wdContext.currentDropDownElement()!=null&&wdContextcurrentDropDownElement().node()!=null)
tableRowElement=wdContext.currentcurrentDropDownElement().node().getParentElement();
String test="DropDown";
String code=tableRowElement.node(test).getCurrentElement().getAttributeAsText("Code");
{color:green}//here Code is an Attribute in the DropDown{color}
wdComponentAPI.getMessageManager().reportSuccess("Country is not null leadSelected:"+code);
}
The above is the code that I have used
Please look into and the O/P is a nulll pointer Exception from the tableRowElement
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.