cancel
Showing results for 
Search instead for 
Did you mean: 

Fix the WD Table column width and table width

Former Member
0 Kudos

Hi experts,

I have a table say ID:TABLE_1 which is already created, now problem we have text column say column1,

when you scroll the scroll bar the size of the table is varying due to the "data"in one of the  Colum. I need to fix the size of the column constantly depending on maxmum length of data.

Ex: column1

     Arun

     Arun Kumar

     Arun Kumar Wading

If this is in ABAP ALV we can fix it with below piece of code

1) we use    ws_layout-colwidth_optimize = 'X'.  In webdynpro table how can we do it?  

2) we can also use wa_fieldlayout-output length for Individual columns .In webdynpro table how can we do it?  

Thanks

Gopal

Accepted Solutions (0)

Answers (2)

Answers (2)

ramakrishnappa
Active Contributor
0 Kudos

Hi Gopal,

You can set the table as "fixed table layout",i.e. the width of table is fixed and the size of columns will be adjusted accordingly based on contents.

Also, you can set the width of a column by using property '"WIDTH". The width can be set like 100%,10PX,10EX,10EM, refer the CSS Units for more info

Hope this helps you.

Regards,

Rama

Former Member
0 Kudos

Hi,

For adjusting the table width to 100%, Use below code

DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage.
  DATA l_salv_wd_table TYPE REF TO iwci_salv_wd_table.
  DATA l_table TYPE REF TO cl_salv_wd_config_table.

l_ref_cmp_usage =   wd_this->wd_cpuse_it_alv( ).

  IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
    l_ref_cmp_usage->create_component( ).
  ENDIF.

  l_salv_wd_table = wd_this->wd_cpifc_it_alv( ).
  l_table = l_salv_wd_table->get_model( ).


  l_table->if_salv_wd_table_settings~set_width( '100%' ).



For setting column width, use below code

DATA LR_COL TYPE REF TO CL_SALV_WD_COLUMN.

LR_COL = L_table->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( '<col_name>' ).

LR_COL->SET_WIDTH( '70' ) .

Thanks

KH

Former Member
0 Kudos

Hi KH,

Thank for the suggestion I am looking for CL_WDATBLE not ALV . Any suggestions please.

Former Member
0 Kudos

Hi Gopal,

You can use SET_WIDTH( ) of class CL_WD_TABLE column to set the width of table and column.

Ex:

"For table width

data lr_table            type ref to cl_wd_table.
lr_table = cl_wd_table=>new_table( id = l_id bind_data_source = l_node_id ).
lr_table->set_width( '100%' ).

"For setting column width

data : lt_columns          TYPE cl_wd_table_column=>tt_table_column,
data :  ls_columns         LIKE LINE OF lt_columns.
data : lr_table_column     TYPE REF TO cl_wd_table_column.

CALL METHOD lo_table->get_columns( RECEIVING the_columns = lt_columns ).

LOOP AT lt_columns INTO ls_columns .
          lr_table_column ?= lo_table->get_column( id  = ls_columns->id ).
               CASE lr_table_column->id.
                   WHEN '<your column>'.

                          ls_columns->set_width( '100px'  ).

                 ENDCASE.

ENDLOOP.

Hope this helps you.

Thanks

KH