Show TOC

Procedure documentationDefining Multiple Cell Editors for a Column Locate this document in the navigation structure

 

If you want to use multiple cell editors for a cell, for example, to align all interactive elements in the first column, use the cell variant CL_SALV_WD_MULTI_CELL_EDITOR. The following interface elements are provided as cell editors:

  • Button

  • LinkToAction

  • LinkToURL

  • FileDownload

  • ToggleButton

This graphic is explained in the accompanying text.

Class diagram for the multiple cell editor

Procedure

Implementing cell variants with multiple cell editors

The following example shows how you insert, for example, all available cell editors into a column (ls_column).

  1. Declare the following variables:

    data:

    lr_cv type ref to cl_salv_wd_multi_cell_editor,

    lr_checkbox type ref to cl_salv_wd_uie_checkbox,

    lr_button type ref to cl_salv_wd_uie_button,

    lr_link_to_action type ref to cl_salv_wd_uie_link_to_action,

    lr_link_to_url type ref to cl_salv_wd_uie_link_to_url,

    lr_file_download type ref to cl_salv_wd_uie_file_download,

    lr_toggle_button type ref to cl_salv_wd_uie_toggle_button.

  2. Instantiate the cell variants and add the key that you need to assign to cell variant of the column:

    create object lr_cv.

    lr_cv->set_key( 'CV_MULTI' ).

  3. Add a button:

    create object lr_button.

    lr_button->set_text( 'myButton' ).

    lr_button->set_image_source( '~Icon/Approve' ).

    lr_cv->add_editor( lr_button ).

  4. Add a LinkToURL:

    create object lr_link_to_url.

    lr_link_to_url->set_image_source( '~Icon/Wiki' ).

    lr_link_to_url->set_text( 'SDN Wiki' ).

    lr_link_to_url->set_reference( 'http://wiki.sdn.sap.com/wiki/display/WHP/Home' ).

    lr_cv->add_editor( lr_link_to_url ).

  5. Add a LinkToAction:

    create object lr_link_to_action.

    lr_link_to_action->set_text( 'Details' ).

    lr_link_to_action->set_image_source( '~Icon/DetailedSettings' ).

    lr_cv->add_editor( lr_link_to_action ).

  6. Add a FileDownload:

    create object lr_file_download exporting data_fieldname = 'FILE'.

    lr_file_download->set_visible( cl_wd_uielement=>e_visible-visible ).

    lr_file_download->set_enabled_fieldname( 'LOCKED' ).

    lr_file_download->set_file_name( 'Data.txt' ).

    lr_file_download->set_text( 'Download' ).

    lr_file_download->set_image_source( '~Icon/File' ).

    lr_file_download->set_mime_type( 'text/plain' ).

    lr_file_download->set_behaviour( cl_wd_file_download=>e_behaviour-allow_save ).

    lr_cv->add_editor( lr_file_download ).

  7. Add a ToggleButton:

    create object lr_toggle_button exporting checked_fieldname = 'LOCKED'.

    lr_toggle_button->set_visible( cl_wd_uielement=>e_visible-visible ).

    lr_toggle_button->set_image_source( '~Icon/Locked' ).

    lr_toggle_button->set_checked_image_source( '~Icon/Unlocked' ).

    lr_cv->add_editor( lr_toggle_button ).

  8. Add the cell variant to the required column:

    ls_column-r_column->add_cell_variant( lr_cv ).

    ls_column-r_column->set_selected_cell_variant( 'CV_MULTI' ).

Note Note

Event Handling

Parameter CELL_EDITOR is provided to determine which interface element was clicked in this column.

For more information, see the system documentation on the events ON_CELL_ACTION and ON_CLICK of INTERFACECONTROLLER SALV_WD_TABLE.

End of the note.

Result

The column with these cell editors looks as follows:

This graphic is explained in the accompanying text.

“One click action": Multiple interactive interface elements in a cell