on 2010 Mar 25 12:15 PM
Hi guys!
A really frequent asked question but I didn't find my answer in all posts around it.
I need to set initial value selected in a dropdown list amoung all entry in this list.
For tis i used context mapping with a 0,n node. I get all my values in the list. I also have a single attribute that hold the initial value to compare with and I wrote the following script at form:ready event of my listbox :
this.selectedIndex = -1;
for (var i = 0; i < this.length; i++)
{
if (this.getSaveItem(i) == $record.attr1.value)
this.setItemState(i,true) = i;
}
And of course nothing happens (or it wouldn't be fun...)!!
Really need your help to get the default selecteded value back from db data.
With Enumerated Drop-down List from WD library the first value should be selected by default.
Also setItemState works for Listbox and for DropdownList, you will need to write as
this.selectedIndex = 0
Also check out JS code to loop all elements for a drop-down in this [wiki|http://wiki.sdn.sap.com/wiki/display/EmTech/JavaScriptforCommonScenarios-PartI]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thx for the answer!
I'll check again my component type but setItemState doesn't work too. The this.selectedIndex = -1 is given to reset selection before choosing another one. I found it in several example. My need is not to select the fisrt element of the list (that is what i get right now) but recall the value saved last time by the application.
If anybody knows...
Another information : it seems that javascript doesn't work at all cause when i set the selected index to a fixed value ( for example 3 on 20 elements in the list) nothing happens too.
Solved!!
In fact that was a problem of binding... I need to bind elements to my 0,n node which contains all values but store the result (link binding) in a 0,1 attribute and then all is working fine.
Double binding : one for the value list the second to result attribute. I've never understood that point from all example i saw... I'm going to check if i need to change my glasses...
User | Count |
---|---|
71 | |
10 | |
8 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.