Reputation: 7622
So, inside the TOOLBAR
event of the CL_GUI_ALV_GRID
the parameter E_OBJECT
has the table MT_TOOLBAR
that I can access to change all the buttons manually.
Is there a better way to include/exclude standard buttons in the toolbar than simply creating them like custom-buttons in the toolbar event?
Upvotes: 2
Views: 19939
Reputation: 1
class lcl_event_alv definition . public section .
methods handle_toolbar for event toolbar of cl_gui_alv_grid
importing e_object e_interactive sender.
class lcl_event_alv implementation .
method handle_toolbar.
delete e_object->mt_toolbar where function = '&LOCAL&INSERT_ROW' or function = '&LOCAL&DELETE_ROW'
or function = '&LOCAL&APPEND' or function = '&LOCAL©'
or function = '&LOCAL&PASTE' or function = '&LOCAL&CUT'
or function = '&LOCAL©_ROW' or function = '&LOCAL&CUT'.
endmethod.
data : go_event type ref to lcl_event_alv.
create object go_event .
set handler go_event->handle_toolbar for go_grid1.
call method go_grid1->set_table_for_first_display
exporting
is_layout = gd_layout
is_variant = value disvariant( report = sy-repid handle = 'GO_GRID1' )
i_save = 'A'
changing
it_fieldcatalog = gt_fcat1
it_outtab = gt_items1.
Upvotes: 0
Reputation: 7250
Similar to REUSE_ALV_GRID_DISPLAY
in class CL_GUI_ALV_GRID
there is also a way.
Define a table of type UI_FUNCTIONS
and a work area of type UI_FUNC
:
data: lt_exclude type ui_functions,
ls_exclude type ui_func.
Append the attributes of the functions you want to hide to the table:
ls_exclude = cl_gui_alv_grid=>mc_fc_sum.
append ls_exclude to lt_exclude.
The attributes of the standard functions all begin with the prefix MC_FC_
, in addition, there is the prefix MC_MB_
for an entire menu in the toolbar.
Pass the table using method set_table_for_first_display
with parameter it_toolbar_excluding
Upvotes: 5
Reputation: 643
If you use REUSE_ALV_GRID_DISPLAY
in your code, this might be helpful for you:
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = 'ZPROGRAM'
i_callback_pf_status_set = 'SET_PF_STATUS'
it_fieldcat = it_fieldcat
tables
t_outtab = gt_itab.
Your SET_PF_STATUS
should be like this in order to eliminate some of the buttons you want. In this example I'm eliminating the "SORT_UP" button.
form set_pf_status using rt_extab type slis_t_extab.
data: lv_flag VALUE 'X'.
if lv_flag is not INITIAL.
append '&OUP' to rt_extab.
endif.
set pf-status 'STANDARD' excluding rt_extab.
endform. "set_pf_status
Hope it was helpful.
Talha
Upvotes: 2