cancel
Showing results for 
Search instead for 
Did you mean: 

DropDownList and setLeadSelection

david_fryda2
Participant
0 Kudos

Hi everyone,

I create da dropdownlistbykey and its value is bound to a simple type I created in the dictionary.

I am not able to set the leading selection to position 1 which is the frst value defined in the disctionary.

Here is the details of the node :

node DataSource

value attribute A

value attribute B

value attribute Currency which is bound the the simple type

I want to display the first value defined in the simple type in Currency.

Should I create another node under DataSource especialy for Currency ?

Thanks for the help.

Regards.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Fryda

Use the LeadSelection Property

Regards

Saravanan K

david_fryda2
Participant
0 Kudos

Hi Saravanan,

Do you mean this


wdContext.nodeNewCurrency().setLeadSelection(1);

?

It does not work.

Thanks.

Former Member
0 Kudos

Hi,

Have you check Cardinality?.

Kind Regards,

S.Saravanan.

Former Member
0 Kudos

David,

Wat you get in the first position? And did you bind the currency value(attribute) to the Texts property of Dropdown by key?

Regards

Saravanan K

Former Member
0 Kudos

David,

Create a seperate node with attribute of type simple and bind this with dropdown texts property

Wat ever be the first in enumeration will come first dropdown..

Set the node's cardinality 1..1

Regards,

david_fryda2
Participant
0 Kudos

Hi,

After doing :

wdContext.nodeDataSource().setLeadSelection(1);

I get the following exception :

java.lang.IndexOutOfBoundsException: Index: 1, Size:1

Cardinality of the node is set to 1..n.

Thanks.

Former Member
0 Kudos

Hi

Try Cardinality of the node is set to 1..1

Kind Regards,

S.Saravanan.

david_fryda2
Participant
0 Kudos

Hi,

I wrote the code in the modify method and it displays in the DDL the value 3.

The cardinality of the node is now set to 1..1.

I do not want that it displays the string 3. I want that it displays what is in position3 of the disctionary.

Thanks

Former Member
0 Kudos

David,

Wat is the structure of Enumeration type?

Saravanan K

david_fryda2
Participant
0 Kudos

Saravan K,

What do you mean ?

I create da dictionary in Simple Type.

Regards.

Former Member
0 Kudos

David,

Try Sridhar's approach. It should work. In your wdDoModifyView(), use this code:


if(firstTime){
IWDDropDownByKey d = (IWDDropDownByKey)view.getElement("DropDownByKey1");
d.setSelectedKey("1"); //Or the key part of the value you want to set.
}

Regards,

Satyajit.

sridhar_k2
Active Contributor
0 Kudos

Hi David,

I have a Simple Type like below.

Values Description

1 -- One

2 -- Two

3 -- Three.

if(firstTime){

IWDDropDownByKey ddkey = (IWDDropDownByKey)view.getElement("DropDownByKey");

ddkey.setSelectedKey("2");

}

Drop Down List Box is giving Default Select as 'Two'.

Is this not the solution you are looking for?

Regards,

Sridhar

david_fryda2
Participant
0 Kudos

Hi Sridhar,

It is the solution I am looking for.

The problem is that it display the string "2" instead of the value defined in the dictionary.

In addition, it works only if you defined a value attribute at the root of the Context. But what happened if you defined a Node and a value attribute in it.

Thanks

Message was edited by: David Fryda

sridhar_k2
Active Contributor
0 Kudos

Hi David,

Do you have entry value - '2' in your simple type (Enumeration) ? If you don't have then it will simply displays '2', wont throw any error. If it has a value, then it shows the 2 - Description 'Two' in DD.

Regards,

Sridhar

david_fryda2
Participant
0 Kudos

Thank you Sridhar for you help.

Regards.

Former Member
0 Kudos

Hi,

Say your enumerated simple type is like this:

Value|Description

1 |Value1

2 |Value2

3 |Value3

Now if you say setSelectedKey("2"), the entry Value2 in your dropdown will be selected. Whatever you are entering as a parameter to setSelectedKey(), should be a key in the enumeration.

<i>But what happened if you defined a Node and a value attribute in it.</i>

What about this? I didn't understand. All you should be doing in this case is bind the selectedKey property to Node.nodeAttribute. Here is nodeAttribute is of type simpletype. Make sure the cardinality of the node is 1...1.

Regards,

Satyajit.

david_fryda2
Participant
0 Kudos

Hi Satyajit,

In fact I defined the cardinality of the node as 1..n.

It works good now.

Thanks.

Answers (2)

Answers (2)

sridhar_k2
Active Contributor
0 Kudos

Hi David,

We can Set lead selection in wdDoModifyView method.

IWDDropDownByKey ddkey = (IWDDropDownByKey)view.getElement("DropDownByKey");

ddkey.setSelectedKey("3");

DropDownByKey - Drop DownBy Key Control Name

3 - Data Dictionary Value.

It will lead to Perticular Element.

Regards,

Sridhar

Former Member
0 Kudos

Hi,

I don't think you can set the lead selection for a enumerated simple type.

It'll be better if you create a value node explicitly for Currency.

Regards,

Satyajit.