cancel
Showing results for 
Search instead for 
Did you mean: 

Wrap text in ALV cell

Former Member
0 Kudos

Hello,

I have an ALV table, and some colums are of type text with quite long lengths.

Initially the columns have a small length, but when the user writes long texts (for example 100 characters) the cell will is automatically enlarged to show the complete text on the screen. That's quite annoying because with two or three columns like this, storing long texts, the overall width of the table is really big.

I know that there is a way to define fixed columns, but the problem with this is that then, when the long text is input in the table, you cannot scroll inside the cell to see the values, you can only see the beginning of the phrase.

I would like to do something similar to the Excel. First I would like to allow the users to resize the columns (just like the Excel grid) and then I would like to wrap long texts in different rows (inside the cell) to reduce the cell width.

Is this possible? What would you recommend in this case?

Regards

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

As described by Uday Gubbala this is all possible. Just be sure to note the point he made about NetWeaver 7.0 Enhancement Package 1. The header wrapping and column resizing (and reordering) were all new functionalities that were delivered as of NetWeaver 7.01 and depend upon the usage of the Lightspeed rendering for Web Dynpro ABAP.

Former Member
0 Kudos

Hello,

at last I've managed to make it work, but there is something I would like to comment about your example. At least in my case the property FIXED_TABLE_LAYOUT must be set to false instead of abap. If you look at the documentation for method set_wrapping

Requirements

The settings that you make with this method only take effect when the following prerequisites have been filled:

You have not fixed the table layout; the width of the column thus depends on the content; the text is always displayed completely

The values in the cells contain characters that can be wrapped (such as spaces or hyphens)

I guess that depends on the webdynpro version. But now I have another question, because it seems that now the column's method SET_WIDTH is not working. As soon as you create the textview for the column the width is automatically set to the header text length and the set_width function doesn't work.

Do you know if it's possible to change the width of a textview? Any advice on this?

0 Kudos

Hi Javier,

I am working on the web dnypro ALV list now and get the same problem as yours. I used the method set_fixed_table_layout( abap_true ) to make the resizing possiable. But as the same time I also use the method set_width for some columns, then it doesn't work. Have you figured out the problem? Is it true that if I use set_fixed_table_layout then I could not set the width any more?

Thanks and best regards,

Wenwen

Former Member
0 Kudos

Hi Thomas.

I have the same requirement, but in my case i am suing editable ALV.

so i have to wrap the text for input field.

Means my cell editor is Input Field and unfortunatlty i could not find any such method in class

cl_salv_wd_uie_input_field.

I dont want header wraping but text wraping in the input field.

so is there any solution for this?

Thanks & Regards,

Arvind

Answers (2)

Answers (2)

uday_gubbala2
Active Contributor
0 Kudos

Hi Javier,

The ALV resize functionality is there in 7.0 Enhp1. It works for standard tables and ALV. You only have to set the fixedTableLayout property to True. You can use the below link to check out Thomas Jung's [demonstration |http://www.flickr.com/photos/tjung/2806011790/]in which he shows as to how we can resize the ALV columns.

  • 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 ).

Regards,

Uday

uday_gubbala2
Active Contributor
0 Kudos

Hi Javier,

The cell wrapping facility is quite possible in ALV. Just go through Thomas Jungs coding in this [thread|;.

Regards,

Uday

Am pasting the same for you over here:

data: l_ref_cmp_usage type ref to if_wd_component_usage.
  l_ref_cmp_usage =   wd_this->wd_cpuse_alv_adv( ).
  if l_ref_cmp_usage->has_active_component( ) is initial.
    l_ref_cmp_usage->create_component( ).
  endif.
 
  data l_salv_wd_table type ref to iwci_salv_wd_table.
  l_salv_wd_table = wd_this->wd_cpifc_alv_adv( ).
  data l_table type ref to cl_salv_wd_config_table.
  l_table = l_salv_wd_table->get_model( ).
 
  data l_column type ref to cl_salv_wd_column.
  data textview type ref to cl_salv_wd_uie_text_view.
  l_column = l_table->if_salv_wd_column_settings~get_column( 'ADD_PARTICIPANTS' ).
  create object textview.
  textview->set_text_fieldname( 'ADD_PARTICIPANTS' ).
  textview->set_wrapping( abap_true ).
  l_column->set_cell_editor( textview ).