cancel
Showing results for 
Search instead for 
Did you mean: 

Controle the WD table column position Sequence

Former Member
0 Kudos

HI All,

How to  controle the WD table column position  (not ALV) in webdynpro as per custom requirnment.

Column1, Column2, Column3, Column4…………

I looked into CL_WD_TABLE to see any possibility.

Can anyone suggest me the right one?

Thanks

Gopal

Accepted Solutions (0)

Answers (2)

Answers (2)

ramakrishnappa
Active Contributor
0 Kudos

Hi Gopal,

we don't have provision to set position of column we do it in ALV by using set_position

As Kiran suggested, you need to delete the existing columns and add the columns as per your requirement by using the parameter INDEX in method ADD_COLUMN / ADD_GROUPED_COLUMN

To get all columns use GET_COLUMNS / GET_GROUPED_COLUMNS

To delete columns use REMOVE_COLUMN(S) / REMOVE_GROUPED_COLUMN(S)

Hope this helps you.

Regards,

Rama

former_member184578
Active Contributor
0 Kudos

Hi,

There is no method(s) to set the column position in table. However, you have to dynamically remove/add using remove_column( ) and add_column( ) by passing index to it in wddomodifyview( ) method dynamically.

Regards,

Kiran

Former Member
0 Kudos

HI Kiran,

Can we rearrange the existing columns of nodes by passing the index and column name.

As I have already have a component with table need to rearrange the columns.

Is there any reference link to cross check it or piece of code that would help me.

Thanks

Gopal.

former_member184578
Active Contributor
0 Kudos

Hi,


Can we rearrange the existing columns of nodes by passing the index and column name.

Unfortunately, No! you have to remove the column and add it.


As I have already have a component with table need to rearrange the columns.

Is it a standard component or custom component?

If it is a custom component, you can rearrange by right click on column and move up/down.

If it is a standard component, consider deleting the table( Remove Element) in enhancement mode and then create a new Table UI with specified order.  Or, create a post exit in wddomodifyview and then get the table reference and use remove_column( ) add_column( ) methods

code snippet:


DATA: lr_table    TYPE REF TO cl_wd_table,

       lr_abs_col TYPE REF TO cl_wd_abstr_table_column,

       lr_col     TYPE REF TO cl_wd_table_column.

  IF first_time EQ abap_true.

* get table reference

      lr_table ?= view->get_element( id = 'TABLE ). " ID of Table UI

     CALL METHOD lr_table->remove_grouped_column

       EXPORTING

         id                = 'COL1' " column

         index             = 1      " index

       RECEIVING

        the_grouped_column = lr_abs_col.

      lr_col ?= lr_abs_col.

     CALL METHOD lr_table->add_column

       EXPORTING

         index              = 20  " new index

         the_column     = lr_col.

  ENDIF.

hope this helps u,

Regards,

Kiran