I try to dynamically build a toolbar depending on given criterias thanks to "toolbar" event in class cl_gui_alv_grid.
The problem is that the toolbar is getting my custom button but as soon as my criteria does not match anymore and that I'd like to remove one button, the toolbar is not getting refreshed. Example here below
"Refresh button
CLEAR ls_toolbar.
ls_toolbar-icon = icon_refresh.
ls_toolbar-quickinfo = TEXT-ref.
ls_toolbar-butn_type = 0.
ls_toolbar-text = TEXT-ref.
ls_toolbar-function = 'REFRESH'.
ls_toolbar-disabled = abap_false.
APPEND ls_toolbar TO e_object->mt_toolbar.
"Save button
IF my_criteria is false.
DELETE e_object->mt_toolbar WHERE function EQ 'SAVE'.
ELSE.
CLEAR ls_toolbar.
ls_toolbar-icon = icon_system_save.
ls_toolbar-quickinfo = TEXT-sav.
ls_toolbar-butn_type = 0.
ls_toolbar-text = TEXT-sav.
ls_toolbar-function = 'LAMA_SAVE'.
ls_toolbar-disabled = abap_false.
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDIF.
When I create my ALV I do call method lo_alv->set_toolbar_interactive( ).
When I go into debug mode I see that the save button is added or removed but it is not getting reflected on the screen once the toolbar has been displayed at leat once.