Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Disable a Push Button in ALV GRID

0 Kudos
4,443

I want to Disable a Push Button that is shown in my ALV. I want to disable that based on other field value.

i used GS_CELLTAB-STYLE     = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED. in my internal table, but didn't acheive the result.

14 REPLIES 14

former_member195402
Active Contributor
0 Kudos
1,349

Hi,

if your field STYLE is of table type LVC_T_STYL then add a line (workarea) of type LVC_S_STYL for your button field:

You have to fill field FIELDNAME with the name of the button field in the workarea.

Clear field STYLE in LVC_S_STYL in the workarea to deactivate the button, move cl_gui_alv_grid=>mc_style_button to field STYLE in the workarea to show the button.

Sample:

DATA: xs_style      TYPE  lvc_s_styl.

DATA: xt_style      TYPE  lvc_t_styl.

    REFRESH                        xt_style. "only once in the beginning of xt_data LOOP for each line

    xs_style-fieldname          =  'MYBUTTON'.

    IF  xs_data-field_xyz       =  'A'.

      xs_style-style            =  cl_gui_alv_grid=>mc_style_button.

    ELSE.

      CLEAR                        xs_style-style.

    ENDIF.

    INSERT  xs_style         INTO  TABLE xt_style.

    xs_data-style               =  xt_style."Line of ALV data table

Regards,

Klaus

0 Kudos
1,349

thanks,

i tried this but the push button is coming wherever required but nothing is coming where the button should be in disabled mode.

0 Kudos
1,349

Okay,

then replace line

      CLEAR                        xs_style-style.

with

      xs_style-style            =  cl_gui_alv_grid=>mc_style_button

                                +  cl_gui_alv_grid=>mc_style_disabled.

Regards,

Klaus

0 Kudos
1,349

this i have already tried.

0 Kudos
1,349

Hi,

meanwhile I think it's not possible to set a button inactive in a grid line.

CL_GUI_ALV_GRID=>MC_STYLE_DISABLED is to make an input field non-editable.

Either you have a button in line or not.

See also this thread for it:

http://scn.sap.com/message/13355726

Regards,

Klaus

0 Kudos
1,349

Hi Klaus,

i tried both but neither work.

      GS_CELLTAB-STYLE     = CL_GUI_ALV_GRID=>MC_STYLE_BUTTON

                            + CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.

and

       GS_CELLTAB-STYLE     = CL_GUI_ALV_GRID=>MC_STYLE_BUTTON

       GS_CELLTAB-STYLE  = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.

0 Kudos
1,349

Yes, definitely no way for setting cell buttons to inactive, see my last post.

Therefore in all of my program I completely cleared this field. Another idea is to set a special background color or an ICON in this case.

Regards,

Klaus

0 Kudos
1,349

Thanks Klaus.

I think this one is the other way i can try.

Former Member
0 Kudos
1,349

show me your's code

0 Kudos
1,349

i have written this code after fetching the records from table. same i am passing in ALV

  LOOP AT GT_/LGC/SDTVINS ASSIGNING <GS_NEW_SDTVINS>.

    IF <GS_NEW_SDTVINS>-TYPE NE 'H'.

      GS_CELLTAB-FIELDNAME = 'DISPLAY'.

      GS_CELLTAB-STYLE     = CL_GUI_ALV_GRID=>MC_STYLE_BUTTON.

      INSERT GS_CELLTAB INTO TABLE <GS_NEW_SDTVINS>-CELLTAB.

    ENDIF.

  ENDLOOP.

Former Member
0 Kudos
1,349

Hi try this,

 

   METHOD event_toolbar.

  data i_button TYPE stb_button.

          i_button-disabled  = 'X'.

         i_button-text = 'BUTTON2'.

         APPEND i_button to e_object->MT_TOOLBAR.

ENDMETHOD.

0 Kudos
1,349

Hi Raji,

this is for toolbar buttons, not for cell buttons.

Regards,

Klaus

Former Member
0 Kudos
1,349

Hi,

Do you want to Disable the button ALV  GRID.

0 Kudos
1,349


No i want to do in ALV grid cell not for the tool bar