cancel
Showing results for 
Search instead for 
Did you mean: 

Initial Value In Drop Down By Key

Former Member
0 Kudos

Hi Experts,

I ahve a drop down by key which has 4 values , but it shows blank as initial load up and i have to expand the dropdown to view the 4 values, could some on please tell me how to set one of my values as the default one so that i wouldnt have a blank entry on first run of the view.

Replies would be gratefully acknowledged,

Chaitanya.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Chaitanya,

In case ur problem is not solved yet..Just change the SELECTION property of the Context node you are binding with the dropdown Key UI element to 1..1.

Hope it will resolve the issue.

Regards,

Amit

Former Member
0 Kudos

I came across the same requirement and dont know whether the way i solved the problem was right or wrong but yes i solved it.

In my case i had 6 values in dropdown by key and first value coming was blank, i just wanted that instead of blank i should get SELECT as default value.

You can use following code to solve this problem (it really removes the blank and puts this value in your DBK by default)

data: node type ref to if_wd_context_node.

DATA: str1 type string.

data: find type if_main=>element_zfind.

str1 = 'SELECT'.

node = wd_context->get_child_node( 'ZFIND' ).

find-zfind = str1.

node->bind_structure( find ).

NOTE: important thing is that you should have this default value (in my case SELECT ) should be there in your value range or else it will give you a DUMP.

try it if u get any problem just ask me.

regards

panky

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

That's fairly simple: you just need to make sure there is a value in the context attribute that is data bound to this UI element.

Former Member
0 Kudos

Hi Thomas,

There is one value which is bound to this dropdown element but that is only visible on expanding the dd (which is blank bfore i expand), i would like it to be displayed when the screen loads up.

Thanks 4 Ur Help,

Chaitanya

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>

> Hi Thomas,

>

> There is one value which is bound to this dropdown element but that is only visible on expanding the dd (which is blank bfore i expand), i would like it to be displayed when the screen loads up.

>

> Thanks 4 Ur Help,

> Chaitanya

I would check your binding, as something must not be correct. What value is in the context attribute that is bound to the selectedKey property will show as selected in the DDLBKey when the screen is first shown. There is nothing you should need to do to make this happen - except properly bind to an attribute that has a value.

alejandro_bindi
Active Contributor
0 Kudos

Chaitanya, check this code and adapt it to yours. I'm assuming you've already built the valueset table so I'm not including that part:


  DATA:
    lt_value_set  TYPE wdr_context_attr_value_list,
    lr_node       TYPE REF TO if_wd_context_node,
    lr_node_info  TYPE REF TO if_wd_context_node_info.

  lr_node = wd_context->get_child_node( wd_this->wdctx_(YOUR NODE) ).
  lr_node_info = lr_node->get_node_info( ).

* Set possible values for the atribute
  lr_node_info->set_attribute_value_set(
      name      = iv_attr_name	" Your attribute bound to the dropdown by key, e.g. 'ATTR1'
      value_set = lt_value_set
  ).
  IF iv_initial_value IS SUPPLIED.
*   Set initial attribute value (it SHOULD exist on the table lt_value_set!)
    lr_node->set_attribute(
        value  = iv_initial_value
        name   = iv_attr_name	" Your attribute bound to the dropdown by key
    ).
  ENDIF.

Regards