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: 

Enable and Desable check box in alv grid with class

former_member219871
Participant
0 Kudos

Hi all...

I searched all posting for this i didn't found.. plz help me

i have a report alv grid in modulepool custom control using class. within that one column contains check boxes for all process order numbers. I need to desable(or remove) check box for repeated process order numbers.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

You can have look into Standard Program BCALV_EDIT_05. Select the checkbox and then double click on it it will be greyed out.

Please use this as reference and then use sort the ITAB on AUFNR and use AT NEW AUFNR. For first AUFNR, edit the checkbox and for others disable.

Shiva

8 REPLIES 8

Former Member
0 Kudos

Hi gupi, for disable checkbox, steps are:

1- define in your output table, a field of type LVC_T_STYL

2- In layout structure that you pass at method first_display, set the field stylefname with the name of output table field you have defined in step 1

3- for lines you want to disable, add a line in field you have created in step 1, with this value:

<your_fieldname>-fieldname = 'field name you want to disable'

<your_fieldname>-style = cl_gui_alv_grid=>mc_style_disabled.

regards.

Andrea

0 Kudos

Hi Andrea..

Thanks for reply..

that code is for disable for rows you sent.

But i would like to disable check box for those order numbers are repeated.

in my alv 1st column is displayed all check boxes and 2nd column is order numbers.

my requirement is to for 1st time order number check box have to active and if it repeates(order bynber) in next row that check box have to disable..

Edited by: gopi macha on Aug 31, 2011 4:40 PM

0 Kudos

Hi Gopi, if i have understood well, you could have such a situation:

row no. checkbox order no.

1 active 1

2 disable 1

3 disable 1

4 active 2

5 disable 2

is that right?

if it is right, you have to:

loop at output_table.

refresh output_table-new_column_created .

if "checkbox should be disable"

add code of my previus post in output_table-new_column_created

endif.

modify output_table.

endloop.

if i haven't well understood your requirements, please try to make them more clear to me

Regards.

Andrea

Edited by: Andrea Marangon on Aug 31, 2011 4:52 PM

0 Kudos

Hi

What Andrea says is right

That code is to enable/disable for imput the field of s row, that means a single cell

Max

Former Member
0 Kudos

Hi

You can have look into Standard Program BCALV_EDIT_05. Select the checkbox and then double click on it it will be greyed out.

Please use this as reference and then use sort the ITAB on AUFNR and use AT NEW AUFNR. For first AUFNR, edit the checkbox and for others disable.

Shiva

0 Kudos

Hi all..

Thanks for reply

I have already checked standard program BCALV_EDIT_05. that is after o/p if we double click on check box greyed out, but need to have before o/p to show required checkboxes greyed.

I used At new ebeln and taken a flag in internal table & respected 'X' row i need to enable checkbox others i have to disable in alv grid and my code already developed using class.

my requirement like this in alv grid:

checkbox Orderno. Itemid

4502000204 10

4502000204 20

by default i have to enable 1st row checkbox and 2nd row checkbox have to disable because it is repeated Order no.

any idea...

0 Kudos

Hi Andrea..

You said my requirement is correct will you expain code clearly in refresh...

Gopi.

0 Kudos

Hi Gopi, the logic is quite simple....

the layout of every cell can be done using a table of type LVC_T_STYL in every line of your output table.

Here you insert, for every field of your output structure, the output style of the cell.

If you want to disable a checkbox for a row, in the field of type lvc_t_styl of the corrisponding row, you need ti insert a line

with the field name of your checkbox, and the style = cl_gui_alv_grid=>mc_style_disabled.

Here an example of what i did in a program: this code color a cell and set non editable.

data: l_color type lvc_s_styl.

loop at t_output .

clear l_color.

refresh t_output-color.

read table wt_pstyv with key pstyv = t_output-pstyv

binary search.

if sy-subrc ne 0.

continue.

endif.

if wt_pstyv-read_only = 'X'.

l_color-style = l_color-style +

cl_gui_alv_grid=>mc_style_disabled.

endif.

l_color-fieldname = 'ARKTX'.

append l_color to t_output-color.

l_color-fieldname = 'KWMENG'.

append l_color to t_output-color.

l_color-fieldname = 'MATNR'.

append l_color to t_output-color.

l_color-fieldname = 'PSTYV'.

append l_color to t_output-color.

modify t_output.

endloop.

Regards.

Andrea