2014 Apr 16 8:40 AM
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.
2014 Apr 16 9:48 AM
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
2014 Apr 16 10:42 AM
thanks,
i tried this but the push button is coming wherever required but nothing is coming where the button should be in disabled mode.
2014 Apr 16 11:08 AM
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
2014 Apr 16 11:41 AM
2014 Apr 16 12:29 PM
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
2014 Apr 16 1:05 PM
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.
2014 Apr 16 1:28 PM
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
2014 Apr 17 6:47 AM
2014 Apr 16 12:34 PM
2014 Apr 16 1:09 PM
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.
2014 Apr 16 12:38 PM
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.
2014 Apr 16 12:40 PM
Hi Raji,
this is for toolbar buttons, not for cell buttons.
Regards,
Klaus
2014 Apr 16 1:00 PM
2014 Apr 16 1:05 PM