cancel
Showing results for 
Search instead for 
Did you mean: 

Default value for dropdown

Former Member
0 Kudos

Hi everyone,

In WD, How to get a first value as a default value for a dropdown.?? I Am not storing the values in domain. I Am appending the values.

Can anyone help us,

Thanks and regards,

vijay

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

In the dropdown if you do not want a blank value to appear first then make the node's selection as 1..1. By doing this the 1st value in the dropdown would by default be the 1st value you are appending to the node.

There is another alternative if you want to retain the 1st blank entry. You can use

LV_NODE->SET_LEAD_SELECTION_INDEX( 0 ).  //defaults to the 1st element in the node

where lv_node is the reference to the node.

Thanks & Regards,

Gayathri Shanbhag

Former Member
0 Kudos

Hi,

I am using Value set.. in a layout there is no option of lead selection. so i am want to do it through code .

Former Member
0 Kudos

Hi Vijay

1. If you are using dropdown by key, then you can setSelectedKey to the key of the key value pair, the value of which you want to be the default value.

2. If you are using dropdown by value then in the code you have to get the reference of the node(through code generator->Read a node and select the node the dropdown is bound to, to get the reference to the node.) and set the lead selection using the following code. Here,say lv_node is the reference to the node you have got

LV_NODE->SET_LEAD_SELECTION_INDEX( 0 )

Thanks & Regards,

Gayathri Shanbhag

Former Member
0 Kudos

Hi Gayathri,

My dropdown is a dynamic selection ,Means it will display the current Fiscal year.

ex : 2011-2012.

So i cant write a value in context tab.

Former Member
0 Kudos

Hi Vijay

How are you populating values into your dropdown? And it is a dropdown by index or dropdown by key??

if your values are not fixed, you can still set default value in the method where you are populating the values dynamically. You would have bound the selected key to some attribute right? Use some logic through code to set the default value to that attribute to which you have bound the selectedkey. Say you want to set the dropdown value to the current financial year all the time you can use sy datum to get the timestamp and extract the date from that and then set the selected key to (currentyear-(currentyear+1)). This is just an example.

Thanks & Regards,

Gayathri Shanbhag

Former Member
0 Kudos

Hi gayathri ,

I am using dropdown by key. Yes i have bind the attribute .

I have wrote a logic to get a fiscal year, but am i couldnt able to get any default value.

Yes in coding part i am confused.

Thanks

vijay

former_member199125
Active Contributor
0 Kudos

Vijay,

whatever the dropdown contents, if you want default value to ddbk, just use the set_attribute method and give the desired value, then that value will display.

Regards

Srinivas

Former Member
0 Kudos

Hi Vijay

If you have got the default value you want to set through your logic, then just set that value you have got to the drop down selected key attribute you have defined. Any value you set to the selected key will be reflected as the default value for that dropdown.

Thanks and Regards,

Gayathri Shanbhag

Former Member
0 Kudos

Hi sanasrinivas,

Thanks. I used your logic . Its working fine..

Thanks a lot for everyone who has helped me in solving the issue.

Answers (1)

Answers (1)

ChandraMahajan
Active Contributor
0 Kudos

Hi,

if you have internal table by which you have appended values then afer binding the table, you can use set_lead_selection method as shown below to set the 1st value as default one.

node->bind_table( int_dd_value).

node->set_lead_selection_index( 1 ).

I am not sure if this is what you are looking for.

Thanks,

Chandra