cancel
Showing results for 
Search instead for 
Did you mean: 

columns can't be made smaller / wider in alv?

Former Member
0 Kudos

Hi all,

I am using ALV table in my application. It contains more than 20 columns. I set the column width as flexible means it will adopt upto the length of column header and data. Now the problem is, user wants to arrange the column width manually. But when i points to cursor in between the columns, i didnt get any symbol to expand/minimize the column.

How to solve this.

Please help me on this.

Thanks,

GS

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Sathishkumar,

You have to set ALV table as "fixed_table_layout".

DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .

DATA lv_value TYPE REF TO cl_salv_wd_config_table.

DATA: lr_table_settings TYPE REF TO if_salv_wd_table_settings.

lo_interfacecontroller = wd_this->wd_cpifc_cu_alv( ).

*--> Get the ALV Model

lv_value = lo_interfacecontroller->get_model(

).

*--> Set it as Fixed Layout

lr_table_settings ?= lv_value.

lr_table_settings->set_fixed_table_layout( abap_true ).

Thanks and Regards,

Vijay

Former Member
0 Kudos

Hi Vijay,

Thank you very much for your reply. But when we use this fixed layout, we can get hat the scroll to maximize and minimize the column. But it automatically, wont arrange as per the column width. If we remove that fixed layout and give the follwing functioanlity,

cl_salv_wd_model_table_util=>if_salv_wd_table_util_stdfuncs~set_all(

r_model = r_table ).

automatic functionality is working. if we give both, then fixed alyout is only working. So i want both the functionality, automatically it should arrange and if user want to make it manually, he should get that symbol to rearrange it.

Thanks,

GS

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi ,

Try like this...

  • create an instance of ALV component

DATA: LR_IF_CONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE,

LR_CMP_USAGE TYPE REF TO IF_WD_COMPONENT_USAGE,

LR_CMDL TYPE REF TO CL_SALV_WD_CONFIG_TABLE,

LR_TABLE_SETTING TYPE REF TO IF_SALV_WD_TABLE_SETTINGS.

LR_CMP_USAGE = WD_THIS->WD_CPUSE_ALV( ).

IF LR_CMP_USAGE->HAS_ACTIVE_COMPONENT( ) IS INITIAL.

LR_CMP_USAGE->CREATE_COMPONENT( ).

ENDIF.

    • get reference to the ALV model

LR_IF_CONTROLLER = WD_THIS->WD_CPIFC_ALV( ).

LR_CMDL = LR_IF_CONTROLLER->GET_MODEL( ).

LR_TABLE_SETTING ?= LR_CMDL.

    • Set column width

DATA LR_COL TYPE REF TO CL_SALV_WD_COLUMN.

LR_COL = LR_CMDL->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'PERNR' ).

LR_COL->SET_WIDTH( '70' ) .

LR_COL = LR_CMDL->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'ENAME' ).

LR_COL->SET_WIDTH( '100' ) .

LR_TABLE_SETTING->SET_FIXED_TABLE_LAYOUT( ABAP_TRUE ).

and go through this...it mightr helps..

Cheers,

Kris.

Edited by: kissnas on Apr 26, 2011 6:34 PM

Former Member
0 Kudos

Hi Sathishkumar,

You can set the Width for each columns. Please refer the below code,

DATA: lr_table_settings TYPE REF TO if_salv_wd_table_settings.

lr_table_settings ?= lo_value.

lr_table_settings->set_fixed_table_layout( abap_true ).

lr_table_settings->set_scrollable_col_count( 15 ).

lt_cols_ref = lo_value->if_salv_wd_column_settings~get_columns( ).

LOOP AT lt_cols_ref INTO ls_col_ref.

CASE ls_col_ref-id.

WHEN 'CARRID' OR 'CONNID'.

*--> Set the Column Width

CALL METHOD ls_col_ref-r_column->set_width

EXPORTING

value = '3%'.

ENDCASE.

ENDLOOP.

Thanks and Regards,

Vijay