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: 

Restrict hideable columns in ALV-Grid

Former Member
0 Kudos

Hello everyone

I have a requirement to restrict the columns which the user can hide in an ALV-Grid. For example i have the column "Project" which needs to be filled and the column "Project description". The user should be allowed to hide the "Project description" column but shouldn't be able to hide the "Project" column. I have already looked for solutions on the web but sadly haven't found any. I also tried intercepting the user command with the "BEFORE_USER_COMMAND" event to edit the variant but it never applies the changes to the fieldcatalog. If you could provide me with any hints or even an answer I'd be very thankful.

Best Regards
Phil

7 REPLIES 7

raymond_giuseppi
Active Contributor
0 Kudos

You could handle the event AFTER_REFRESH of the ALV grid. Read the frontend field catalog. If and only some forbidden fields were hidden, update and set again the frontend field catalog and refresh the table display.

0 Kudos

Hi Raymond

Sounds like an interesting approach but I think it'll be heavy on performance when i am constantly updating the frontend object. Nontheless thanks for your answer

Regards
Phil

0 Kudos

I use this in some programs where subtotals are calculated from (strange) user rules and don't get performance problem. Of course I force a new display only when something (field catalog, total values, sort criteria) actually changed, so no refresh most of the time.

bertrand_delvallee
Active Participant

Hello,

Did you try to fill field KEY in fieldcat?

    DATA t_fieldcatalog	TYPE lvc_t_fcat.
    FIELD-SYMBOLS <fieldcatalog>  TYPE LINE OF lvc_t_fcat.
    grid->get_frontend_fieldcatalog( IMPORTING et_fieldcatalog = t_fieldcatalog ).
    LOOP AT t_fieldcatalog ASSIGNING <fieldcatalog>.
      CASE <fieldcatalog>-fieldname.
        WHEN 'FIX_COLNAME'.
          <fieldcatalog>-key = 'X'.
          clear <fieldcatalog>-no_out.
      ENDCASE.
    ENDLOOP.
    grid->set_frontend_fieldcatalog( t_fieldcatalog ).

Best regards,

Bertrand

0 Kudos

Hi Bertrand

Thanks for your answer. I haven't tried it yet, but in my expirience the field will get colored blue. I'll also try if using custom cellcolor will override this effect.

Regards
Phil

0 Kudos

Hi Bertrand

I have just tried it sadly the columns can still be hidden. But thanks for your suggestion.

Regards
Phil

Former Member
0 Kudos

Hello everyone

I wanted to thank everyone for their answer but we have scrapped this approach and decided that all columns can be hidden and the user is responsible on what columns they'll hide.

Regards
Phil