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: 

selective edit in ALV grid

henk_devries2
Explorer
0 Kudos

Hi,

I am using the REUSE_ALV_GRID_DISPLAY_LVC function to display a grid. In this grid I have some columns containing checkboxes that are editable. But, depending on some data in de records that I show, some of these checkboxes should be non-editable. Does anyone of you have an idea how to do this?

regards,

Henk

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

add the field to the table declaration.

DATA cellstyles TYPE lvc_t_styl .

now tell the layout about this styling field.

ps_layout-stylefname = ‘CELLSTYLES’.

DATA ls_listrow LIKE LINE OF pt_list(the displayed table) .

DATA ls_stylerow TYPE lvc_s_styl .

DATA lt_styletab TYPE lvc_t_styl .

here the seatmax(carrid) is not editable if the value is'XY' and planetype(connid) is editable if the value is '02'

LOOP AT pt_list INTO ls_listrow .

IF ls_listrow-carrid = 'XY' .

ls_stylerow-fieldname = 'SEATSMAX' .

ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled .

APPEND ls_stylerow TO lt_styletab .

ENDIF .

IF ls_listrow-connid = '02' .

ls_stylerow-fieldname = 'PLANETYPE' .

ls_stylerow-style = cl_gui_alv_grid=>mc_style_enabled .

APPEND ls_stylerow TO lt_styletab .

ENDIF .

INSERT LINES OF lt_styletab INTO ls_listrow-cellstyles .

MODIFY pt_list FROM ls_listrow .

ENDLOOP .

hope this helps.

regards,

vidya.

3 REPLIES 3

Former Member
0 Kudos

Usually this is done something like this.

Add a column STYLE TYPE LVC_T_STYL to your internal table. This becomes a nested internal table. Now, for each row of the internal table, fill up the STYLE table with each column and the style as CL_GUI_ALV_GRID=>MC_STYLE_ENABLED OR CL_GUI_ALV_GRID=>MC_STYLE_DISABLED. This will make sure that the selective columns of specific rows are enabled for editing.

Regards,

Ravi

Note : Please mark all the helpful answers

Former Member
0 Kudos

Hi,

add the field to the table declaration.

DATA cellstyles TYPE lvc_t_styl .

now tell the layout about this styling field.

ps_layout-stylefname = ‘CELLSTYLES’.

DATA ls_listrow LIKE LINE OF pt_list(the displayed table) .

DATA ls_stylerow TYPE lvc_s_styl .

DATA lt_styletab TYPE lvc_t_styl .

here the seatmax(carrid) is not editable if the value is'XY' and planetype(connid) is editable if the value is '02'

LOOP AT pt_list INTO ls_listrow .

IF ls_listrow-carrid = 'XY' .

ls_stylerow-fieldname = 'SEATSMAX' .

ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled .

APPEND ls_stylerow TO lt_styletab .

ENDIF .

IF ls_listrow-connid = '02' .

ls_stylerow-fieldname = 'PLANETYPE' .

ls_stylerow-style = cl_gui_alv_grid=>mc_style_enabled .

APPEND ls_stylerow TO lt_styletab .

ENDIF .

INSERT LINES OF lt_styletab INTO ls_listrow-cellstyles .

MODIFY pt_list FROM ls_listrow .

ENDLOOP .

hope this helps.

regards,

vidya.

henk_devries2
Explorer
0 Kudos

Thanks a lot!!! This works perfect