cancel
Showing results for 
Search instead for 
Did you mean: 

Toggle button in ALV WebDynpro ABAP

former_member450029
Participant
0 Kudos

Hi experts,

I have to create a button which can toggle in WebDynpro ALV toolbar.

I should be able to change the text as well as the image.

Below are the snippets.

to

and vice versa.

BR,

Eshwar

Accepted Solutions (0)

Answers (2)

Answers (2)

ramakrishnappa
Active Contributor
0 Kudos

Hi Eshwar,

As suggested, use the class CL_SALV_WD_FE_TOGGLE_BUTTON to create toggle button and use methods

For setting image: SET_IMAGE_SOURCE ( )

for setting text : SET_TEXT( )

checked image : checkedImageSource

Check the below wiki, which guides through the toggle button in alv toolbar

SAP List Viewer - ALV - Web Dynpro ABAP - SCN Wiki

Hope this helps you.

Regards,

Rama

former_member450029
Participant
0 Kudos

Hi,

   When I use the below code I am getting dump.

    data:  lr_buttonui      TYPE REF TO cl_salv_wd_fe_toggle_button,

             button            TYPE REF TO cl_salv_wd_function.


   CREATE OBJECT lr_buttonui

     EXPORTING

       CHECKED_ELEMENTNAME = 'CHECKED'.


  lr_buttonui->set_text( 'Select All Attacments' ).

   lr_buttonui->set_image_source( 'ICON_OKAY' ).

   lr_buttonui->set_checked_image_source( 'ICON_OKAY' ).

   lr_buttonui->set_tooltip( 'Select All Attachments' ).

   button = lv_value->if_salv_wd_function_settings~create_function( id = 'ALLA' ).

   button->set_editor( lr_buttonui ).

BR,

Eshwar

ramakrishnappa
Active Contributor
0 Kudos

Hi Eshwar,

You need to create a context node "FUNCTION_ELEMENTS" in your component with cardinality ( 1..1) and create an attribute "CHECKED" and map this onto ALV component's interface controller "FUNCTION_ELEMENTS " node.

So that your issue would resolve.

Regards,

Rama

former_member450029
Participant
0 Kudos

Hi,

Thanks, that one is solved.

Now how to toggle.,

I have a custom button on ALV toolbar with text and an image, when I click on the button text should change and image should change.

I have created a event handler method using the event ON_FUNCTION.

Now in this method, say

case .

when 'TOGGLE'

-----

-----what should be implemented or should I follow any other approach

------

endcase.

Thanks & BR,

Eshwar

ramakrishnappa
Active Contributor
0 Kudos

Hi Eshwar,

Create an attribute in View of type toggle button GO_TOGGLE_BUTTON, when you create button first time save the reference

     wd_this->go_toggle_button =  lr_buttonui

Now, on action,

set the text and image source by using method set_image_source( ) and set_text based on condition.

case .

when 'TOGGLE'

     wd_this->go_toggle_button->set_image_source( "ICON_DUMMY" ).

     wd_this->go_toggle_button->set_text( "Deselect All" ).

when others.

     wd_this->go_toggle_button->set_image_source( "ICON_CHECKED" ).

     wd_this->go_toggle_button->set_text( "Select All" ).

endcase.

Hope this helps you.

Regards,

Rama

former_member184578
Active Contributor
0 Kudos

Hi,

You write the same code again and set the different text and image. Instead wrap the code inside a method and call that method.

Regards,

Kiran

former_member184578
Active Contributor
0 Kudos

Hi,

check this document Add custom functions in ALV Toolbar Instead of button you can use CL_SALV_WD_FE_TOGGLE_BUTTON for Toggle button.

hope this helps,

Regards,

Kiran

former_member450029
Participant
0 Kudos

Hi,

I need to toggle text as well as image.

Sample code would be appreciable.

BR,

Eshwar