cancel
Showing results for 
Search instead for 
Did you mean: 

selected value in dropdown list box

Former Member
0 Kudos

hi forums,

how to capture the selected value in drop down list box and how it will link with the table.

layout:

<htmlb:dropdownListBox id = "d1%>"

nameOfKeyColumn = "vbeln"

nameOfValueColumn = "vbeln"

table = "<%=it_sales%>" />

in dropdown list box,how do i capture the selected values.

OnInitialization:

Select vbeln from vbak

into corresponding fields of table it_sales.

regards,

ravi.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi You can capture the selected value as follows:

Use the attribute <b>selection</b>Refer to the sample code below:

<htmlb:dropdownListBox id      = "DDLB1"
             table             = "<%= projectid_tab %>"
             selection         = "<%= tab1sel %>"
             nameOfValueColumn = "name"
             nameOfKeyColumn   = "value" />

Now in OnInput Processing Event handler you can capture the value using:

CALL METHOD request->get_form_field
      EXPORTING
        name  = 'DDLB1'
      RECEIVING
        value = tab1sel.

tab1sel is declared as a page attribute. You can refer to this code and change it as per your requirement.

Hope this helps!

Best Regards,

Ravikiran.

Former Member
0 Kudos

hi Ravikiran,

In button even,we r mension the event_type = 'click'.

but in dropdownListBox what is the event_type.

i tryed like this.

DATA : EVENT TYPE REF TO CL_HTMLB_EVENT.

***this is for button************

*event = CL_HTMLB_MANAGER=>get_event( RUNTIME->SERVER->REQUEST ).

*IF event->NAME = 'button' AND event->event_TYPE = 'click'.

  • DATA : button_event TYPE REF TO CL_HTMLB_EVENT_BUTTON.

  • button_event ?= event.

*ENDIF.

*********this is for dropdownListBox**********

event = CL_HTMLB_MANAGER=>get_event( runtime->server->request ).

IF event->name = 'dropdownListBox' AND event- >event_type = 'selection'.

DATA : dd_listbox_event TYPE REF TO CL_HTMLB_EVENT_SELECTION.

dd_listbox_event ?= event.

CASE EVENT->ID.

when 'id1'.

CALL METHOD REQUEST->GET_FORM_FIELD

EXPORTING

NAME = 'id1'

RECEIVING

VALUE = SEL.

  • WHEN 'myButton'.

*

  • CALL METHOD REQUEST->GET_FORM_FIELD

  • EXPORTING

  • NAME = 'id1'

  • RECEIVING

  • VALUE = SEL.

ENDCASE.

endif.

with regards,

ravi.

guillaume-hrc
Active Contributor
0 Kudos

Hi,

The event type is <b>'select'</b>.

But you could have easily found it with a one-minute debug

Best regards,

Guillaume

Former Member
0 Kudos

Hi,

If you want the Drop Down List box to trigger an event then,<b>Onselect</b> attribute does that-

<htmlb:dropdownListBox id         = "DDLB1"
                nameOfKeyColumn   = "NAME"
                nameOfValueColumn = "VALUE"
                table             = "<%= tab1 %>"
                onSelect          = "DDLB1Event"
                selection         = "<%= tab1sel %>"
                />

Now in OnInputProceesing you can do like this:

DATA: event      TYPE REF TO if_htmlb_data,
        ddlb_event TYPE REF TO cl_htmlb_event_selection.
DATA: data TYPE REF TO cl_htmlb_dropdownlistbox.
event = cl_htmlb_manager=>get_event( request ).
IF event IS NOT INITIAL .
  ddlb_event ?= event.
IF ddlb_event->id EQ 'DDLB1' .
   tab1sel = ddlb_event->selection .
ENDIF.
ENDIF.

Now your tab1sel will have the value selected. Is this what you are looking for?

Regards,

Ravikiran.

Former Member
0 Kudos

Hi Ravi,

In the layout add the following code,

<htmlb:dropdownListBox id="dbox" table="<%= it_mara %>"

onSelect="matnr" nameOfKeyColumn="matnr" nameOfValueColumn="matnr"></htmlb:dropdownListBox>

and in the oninput processing add the following code,

DATA : EVENT TYPE REF TO CL_HTMLB_EVENT.

event = CL_HTMLB_MANAGER=>get_event( runtime->server->request ).

IF event->name = 'dropdownListBox' AND event->event_type = 'select'.

DATA : dd_listbox_event TYPE REF TO CL_HTMLB_EVENT_SELECTION.

dd_listbox_event ?= event.

v_matnr = dd_listbox_event->selection.

endif.

with this v_matnr wiill get the selected value.dont forget to add v_matnr as page attribute.

regards,

Azaz Ali.

Former Member
0 Kudos

hi Ravikiran,

thanks for u'r help.i got a o/p.

now i am facing the diff. probs.

i want to trigger the eventhandler event only once.

i written two select stmt,one in onInitialization for filling the dropdownlist box and another select stmt for selected dropdownlist value.

here what probs. i faced is,onInitialization event select stmt fills the o/p table values.even i am used the selected value in the dripdownlist box.

so want to trigger the onInitialization only once at the time of filling the dripdownlist box only.

share me u'r idea.

with regards,

ravi.

Former Member
0 Kudos

Hi Ravi,

Keep your OnIntialization code in onCreate Event handler. Is your application stateful?

Regards,

Ravikiran.

Former Member
0 Kudos

Hi Ravi,

Have a condition,

If it_sales[] is initial.

write your select statement here...

endif.

Regards,

Azaz Ali.

Answers (3)

Answers (3)

Former Member
0 Kudos

hi ravikiran,

I want to perform some action once i have selected a value from the dropdownlist box.whats the event_type for dropdown listbox.With the following code the event is not getting triggered.please help me out.

DATA : EVENT TYPE REF TO CL_HTMLB_EVENT.

event = CL_HTMLB_MANAGER=>get_event( runtime->server->request ).

IF event->name = 'dropdownListBox' AND event->event_type = 'selection'.

DATA : dd_listbox_event TYPE REF TO CL_HTMLB_EVENT_SELECTION.

dd_listbox_event ?= event.

perform action

endif.

with regards

sireesha

shiva_suvarna
Participant
0 Kudos

Hi ravi,,

See the example,

<b>sbspext_htmlb/DropdownListBox.bsp</b>

Regards,

shiva

guillaume-hrc
Active Contributor
0 Kudos

Hi Ravi,

On the server side, in the OnInputProcessing handler, you can use this code:

DATA: datad    TYPE REF TO cl_htmlb_dropdownlistbox.
datad ?= cl_htmlb_manager=>get_data( request = runtime->server->request
                                           name    = 'dropdownListbox'
                                           id      = '<IdDDLB>' ).

CASE datad->selection.
*  logic here
ENDCASE.

Hope it helps.

Best regards,

Guillaume