cancel
Showing results for 
Search instead for 
Did you mean: 

Enable / Disable Button in ALV

Former Member
0 Kudos

Hi Experts,

it is possible to enable in the first row of an ALV a button and

in the second one to disable the button of an ALV and in the next one enable and so on?

If it is possible how can I do this?

Thanks in advance!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Yeah you can do it. First set the cell editor of your column as a button, I assume you have done that already. Then create a context attribute button_enabled in the SAME node, of type char01. When you set the cell editor using a button reference, say lr_button of type cl_salv_wd_uie_button, bind the enabled property to the context attribute button_enabled. Do this by

lr_button->set_enabled_fieldname( 'BUTTON_ENABLED' ).

When you populate the internal table to display in the ALV, loop thru the table and set button_enabled = abap_true and abap_false alternatively. Or whatever depending on your logic. The rows for which the field is false will be disabled and others will be enabled. Hope it is clear.

Regards

Nithya

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello!

Yes it is possible, you need to define cell variants for your column. One cell variant should have a button that is enabled and other cell variant should have a button that is disabled.

Now in your context, you need an attribute selectedVariant (string). This will hold the value of the variantKey for each cell.

Regards,

Neha

Former Member
0 Kudos

Ok, thanks for your answer !

Maybe you can post some example code how can I add a cell Variant

and how I have to handle this?

Maybe one tutorial existed about that?

Former Member
0 Kudos

Hello,

I just learned that you can do this just by binding the enable property of your button to an attribute (say enable_button - wdy_boolean)in your context element.

Regards,

Neha

Former Member
0 Kudos

have a look at component SALV_WD_DEMO_TABLE_CV in method ON_UPLOAD_COMPLETE of component controller.