SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Customizing toolbar in ALVTree



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Wed Sep 05, 2007 7:06 pm    Post subject: Customizing toolbar in ALVTree Reply with quote

Author: Vidya Gugnani

Often, one requires customizing the toolbar that appears in an ALV Tree and taking specific actions on choosing this button by triggering the specific handlers.
The following code snippet shows how this can be done in ABAP OO assuming you have a class which requires this handling and the following methods in the same will help you achieve this.
The following code snippet assumes that a filter button appears on given conditions only in the ALV tree and requires to be turned off at other times.
This is achieved in the following manner:
Assume the ALVTRee is created and now we wish to customize the toolbar for the same:
p_filter is the flag which decides if the filter button requires to be visible or not.

******************************************************************
*Create ALV tree prior to this in create_my_tree() method.
*Change the toolbar to suit our needs,pass the tree and filter as parameters.
.........
method create_toolbar.
create_my_tree().
if f_alvtree is not initial. __call_toolbar( tree = f_alvtree filter = p_filter ).
endif.
endmethod.
******************************************************************
*You could specify the toolbar by passing the instance variable f_toolbar which stores the toolbar instance and the filter options.
method __call_toolbar.

check tree is not initial.
tree->get_toolbar_object( importing er_toolbar = f_toolbar ).
f_filter_opt = filter.
__customize_toolbar( alvtreebar = f_toolbar refresh = f_filter_opt ).

endmethod.
******************************************************************
*Specify the tooltips that you wish for your toolbar items. Here *iconquick is a text icon defined in the dictionary.
*It also is optimal to group your icons in an icon package. Raise the event for handling the icon change ,define an event as below in your class.
******************************************************************
method __customize_toolbar.

data : l_tooltip type iconquick.

if alvtreebar is not initial.

*----------------------------------------------------
call method alvtreebar->delete_button
exporting
fcode = 'SHOW_GRID'.
* ----------------------------------------------------
if refresh = ''. " Filter is off so add filter off button
clear: l_tooltip.
l_tooltip = 'Switch on Filter '(add).
call method alvtreebar->add_button
exporting
butn_type = cntb_btype_button
quickinfo = l_tooltip
icon = icon_filter_undo
fcode = 'FILON'.
else.
* ----------------------------------------------------
clear: l_tooltip." Add filter on button
l_tooltip = 'Switch off Filter'(fil).
call method alvtreebar->add_button
exporting
butn_type = cntb_btype_button
quickinfo = l_tooltip
icon = icon_filter
fcode = 'FILOFF'
is_disabled = ''.
endif.
* ----------------------------------------------------

raise event change_tree_toolbar
exporting
im_toolbar = alvtreebar.
* ----------------------------------------------------

set handler __handle_filter_selected for alvtreebar.

endif.
******************************************************************
* This method actually deals with the change on filter appearing/disappearing.
method __handle_filter_selected.

case fcode.

when 'FILOFF'.
check f_toolbar is not initial.
f_filter_opt = ''.
__handle_filter( ).
f_filter_opt = 'X'.

when 'FILON' .
check f_toolbar is not initial.
f_filter_opt = 'X'.
__handle_filter( ).

when others.

endcase.

endmethod.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.