cancel
Showing results for 
Search instead for 
Did you mean: 

dropdown in dynamic alv

Former Member
0 Kudos

Hi,

I have created one dynamic alv in webdynpro abap.

Now I have to put drop down in some of its columns.

Can anyone help in creating drop down in dynamic alv column?

If the alv is static we can create an attribute of type WDR_CONTEXT_ATTR_VALUE_LIST inside the alv node. and populate it with required values but here the alv is dynamic and so the context node.

So how can we achieve the same functionality for dynamic alv.

Regard's,

Puneet

Accepted Solutions (1)

Accepted Solutions (1)

RicardoRomero_1
Active Contributor
0 Kudos

Hi Punnet,

Try the following when you create your ALV:


DATA:

lo_column   TYPE REF TO cl_salv_wd_column,

lo_interfacecontroller TYPE REF TO iwci_salv_wd_table,

lo_model    TYPE REF TO cl_salv_wd_config_table,

lo_drop TYPE REF TO CL_SALV_WD_UIE_DROPDOWN_BY_KEY.

  lo_interfacecontroller = wd_this->wd_cpifc_alv( ).

   lo_model = lo_interfacecontroller->get_model( ).

CALL METHOD lo_model->if_salv_wd_column_settings~get_columns

     RECEIVING

       value = lt_columns.


LOOP AT lt_columns INTO ls_columns.


lo_column = ls_columns-r_column.

IF ls_columns-id EQ  'YOUR_FIELD_LIST'.


       CREATE OBJECT lo_drop

         EXPORTING selected_key_fieldname = 'YOUR_FIELD_LIST'.

       CALL METHOD lo_column->set_cell_editor

         EXPORTING

           value = lo_drop.


     ENDIF.

    


ENDLOOP.


DATA  lo_nd_table_alv_info TYPE REF TO if_wd_context_node_info.

DATA lo_nd_tabla_alv TYPE REF TO if_wd_context_node

DATA: lt_valueset TYPE TABLE OF wdr_context_attr_value,

       ls_valueset TYPE wdr_context_attr_value.

 

     lo_nd_table_alv = wd_context->get_child_node( name = 'TABLE_ALV' ). "Your dynamic node

     lo_nd_table_alv_info = lo_nd_table_alv->get_node_info( ).

     ls_valueset-value = 'FIRST'.

     ls_valueset-text = 'FIRST'.

     APPEND ls_valueset TO lt_valueset.

     ls_valueset-value = 'SECOND'.

     ls_valueset-text = 'SECOND'.

     APPEND ls_valueset TO lt_valueset.

     lo_nd_tabla_alv_info->set_attribute_value_set( EXPORTING name = 'YOUR_FIELD_LIST'

                                                     value_set = lt_valueset ).




Regards,

Ricardo.



Former Member
0 Kudos

Hi Ricardo,

Thanks for the explanation, that was really helpful.

I was able to create dropdown in alv,  However I am facing one issue.

After selecting one of the value from dropdown it displays in column for sometime (approx. 1 or 2 seconds) and then disappears.

Apart from the above issue, I have to make one the dropdown value as default, when the alv displays for the first time, currently it is showing blank in the dropdown column.

Thanks !

Regards,

Puneet

RicardoRomero_1
Active Contributor
0 Kudos

Hi Punnet,

It's strange that the values are disappearing. If you have code in your WDDOMODIFYVIEW to init your ALV check you are doing it only when the parameter FIRST_TIME is set to X.

To set a default value you can hide the standard button "APPEND ROW" and create a custom one, then at the time of append a new row create it with the default values you want.
Check this thread:

default values on click of append row in alv | SCN


Regards,
Ricardo.

Former Member
0 Kudos

Hi Ricardo,

Thanks for the quick response.

Yes I have coded for alv in modifyview method as I have to display dynamic alv.

Columns of alv are dynamic based on the input through drop-down in selection screen.

If I will use first_time parameter, then after changing the value in selection screen dropdown (in first view) the alv list (in the second view) will not change.

And regarding setting the default values- my requirement was to set the default value in drop down column of alv.

suppose in alv drop down column we have two values : First and second (as you showed in screenshot of your answer) then by default first should be selected when we display alv. currently it is blank and user has to select one of the two values first and second.

I have already hide the standard buttons in alv like append row, insert row, check etc.

Regards,

Puneet

RicardoRomero_1
Active Contributor
0 Kudos

Hi,

May be you can create an attribute in your component (or assistance class) and mark it to X when a value in your selection screen is selected (use the event onSelect in your dropdown). Then in your second view if this attribute is set to X clear the value and do the things in your MODIFYVIEW method. In this way you can avoid the use of the FIRST_TIME parameter and the code is not being executed all the time in your view; Only when you change the value in your selection screen.

For the default values; The first time your ALV is displayed, does it have any row?

I think you can create the new rows with the values you want as default using a custom button.

Regards,

Ricarod.

Answers (0)