简体   繁体   中英

ALV Grid lock specific rows

I am using the CL_GUI_ALV_GRID class to display a table. I would like to be able to edit the table (adding new rows and removing all lines), but I don't want existing rows to be editable. That means:

I've got 5 records to display, and I would like to be able to remove and add new records but I don't want the user to edit the 5 existing records (I'd like him to be able to remove them).

Is that possible?

By default when you call the 'LVC_FIELDCATALOG_MERGE' function module to generate a field catalog for the CL_GUI_ALV_GRID, the cells are not editable.

You must set which column is going to be edited setting the 'edit' attribute like this:

...
data: it_fieldcat type lvc_t_fcat,
      wa_fieldcat like line of it_fieldcat.

call function 'LVC_FIELDCATALOG_MERGE'
  EXPORTING
    i_structure_name = 'ZSTRUCT'
  CHANGING
    ct_fieldcat      = it_fieldcat.

loop at it_fieldcat into wa_fieldcat.
  wa_fieldcat-edit = 'X'. " ---->Here is set the editable column
  modify it_fieldcat from wa_fieldcat.
endloop.

If you don't want cells to be edited do not set this attribute.

But for better reference check programs 'BCALV_EDIT_03' and 'BCALV_EDIT_04' for complete examples.

Hope it helps.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM