2009 Jul 01 3:40 PM
Hello,
I'm using REUSE_ALV_GRID_DISPLAY with optimize column width set ON.
I'm allowing users to edit a column that can have from one to fifty characters.
When the grid is initially displayed, if the longest string in this editable column is twenty characters, the optimize column width works just fine.
However, if the user enters a string longer than 20 characters, the column does not re-optimize its width.
I tried refreshing the grid after the user edits the column but that does not work.
So my question:
Is it possible to programatically have the grid re-optimize the column width?
Thx.
Andy
2009 Jul 02 3:08 PM
Andy,
I don't know the answer to you question, but try this and see what happens.
1) Execute with initial data (20 chars in the column)
2) Modify and make it 30
3) Change the layout, go to "Display" tab, check "Optimize Columns" box, and execute
Did it now optimize column width? If it did, then you can debug and see what SAP did. If it did not, as a last resort, you can remove column width optimization and make all of them full width all the time.
2009 Jul 02 1:34 PM
Hi,
Don't you put a code piece like the following one:
C_it_layout-colwidth_optimize = 'X'.
where you are building the layout?
Regards.
2009 Jul 02 3:08 PM
Andy,
I don't know the answer to you question, but try this and see what happens.
1) Execute with initial data (20 chars in the column)
2) Modify and make it 30
3) Change the layout, go to "Display" tab, check "Optimize Columns" box, and execute
Did it now optimize column width? If it did, then you can debug and see what SAP did. If it did not, as a last resort, you can remove column width optimization and make all of them full width all the time.
2013 Aug 30 3:04 PM
Hi Andrew,
try this in the end of form USER_COMMAND, works with ALV_GRID perfectly
DATA: l_grid(33),
ls_layout TYPE lvc_s_layo.
FIELD-SYMBOLS <fs_grid> TYPE REF TO cl_gui_alv_grid.
UNASSIGN <fs_grid>.
l_grid = '(SAPLSLVC_FULLSCREEN)GT_GRID-GRID'.
ASSIGN (l_grid) TO <fs_grid>.
IF <fs_grid> IS ASSIGNED.
CLEAR ls_layout.
CALL METHOD <fs_grid>->get_frontend_layout
IMPORTING
es_layout = ls_layout.
IF sy-subrc EQ 0.
ls_layout-cwidth_opt = 'X'.
CALL METHOD <fs_grid>->set_frontend_layout
EXPORTING
is_layout = ls_layout.
ENDIF.
2021 Feb 09 1:58 PM
Hi.
"3) Change the layout, go to "Display" tab, check "Optimize Columns" box, and execute"
WHERE?
Thank you.
2021 Feb 09 2:57 PM
Declare the layout :
DATA: LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FCAT TYPE LINE OF SLIS_T_FIELDCAT_ALV.
* And insert in IS_LAYOUT