Defining Multiple Cell Editors for a Column
Use
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
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).
-
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.
-
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' ).
-
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 ).
-
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 ).
-
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 ).
-
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 ).
-
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 ).
-
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' ).
Result
The column with these cell editors looks as follows: