cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Table modification

Former Member
0 Kudos

Hello,

I am creating a table (lr_table) dynamically using the CL_WD_DYNAMIC_TOOL=>CREATE_TABLE_FROM_NODE function. This is working fine and the table is populated accordingly.

However, I need the first column of the table to be a radio button, so, I get the column (lr_column) with the lr_table->GET_COLUMN function, create a radio button instance, lr_button, and use the function lr_column->SET_TABLE_CELL_EDITOR( lr_button ). The bindings and value sets are all working.

The problem is that when I do this, the table switches the column order. The first column, wich has the radio button, is shown in second place.

Has anyone come across a similar problem?!

I've searched the foruns but couldn't fine an aswer...

Thanks in advance.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi, I did in fact resolve this issue using lr_column->set_fixed_position( CL_WD_ABSTR_TABLE_COLUMN=>E_FIXED_POSITION-LEFT ).

Although this is not listed as a method of the CL_WD_TABLE_COLUMN type, it actually worked.

Still no idea of why this happened, I create three tables inside a loop clause, from three context nodes with exactly the same structure and only in the first one I got this "bug"!

Thx for the support,

Gonçalo Nolasco

uday_gubbala2
Active Contributor
0 Kudos

Isn't this fixedPosition property what I had proposed in the thread above?

Regards,

Uday

Former Member
0 Kudos

Yes it is.

Yesterday, by mistake, I double posted the thread and replied to the other one.

Thx again.

Regards,

Gonçalo Nolasco

ChrisPaine
Active Contributor
0 Kudos

Sounds like the change of the editor is removing and adding the column to the table.

As there is no "set column order" method, I'd suggest firstly getting all the columns from your table using

table->get_columns

then altering the the column you want - as you have, and then removing all the columns using

table->remove_all_columns

and then finally re-adding them in the order you want them displayed

table->add_column.

Hope this helps,

Chris

uday_gubbala2
Active Contributor
0 Kudos

Hi Chris,

A small correction to what you had quoted. We do have the method set_position available for changing the order of an ALV column.

Regards,

Uday

You can use the below code snippet to change the position of the column SEATCOSS from the existing position to 3.

DATA: lr_column TYPE REF TO cl_salv_wd_column,
            lo_value TYPE REF TO cl_salv_wd_config_table,
           l_ref_cmp_usage TYPE REF TO if_wd_component_usage.

  l_ref_cmp_usage =   wd_this->wd_cpuse_alv( ).

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

* Get config model
  DATA: l_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table .
  l_ref_interfacecontroller = wd_this->wd_cpifc_alv( ).

lo_value = l_ref_interfacecontroller->get_model( ).


lr_column = lo_value->if_salv_wd_column_settings~get_column(id = SEATSOCC').

DATA: ls_column TYPE salv_wd_s_column_ref.

ls_column-r_column = lr_column.
ls_column-r_column->set_position( 3 ).

uday_gubbala2
Active Contributor
0 Kudos

Forgot to mention something.. By default all columns have position set to 0. Columns are added u2018left justifiedu2019 to the table. This means that you can change the position of just one column without the need to explicitly set the position of all columns.

Regards,

Uday

ChrisPaine
Active Contributor
0 Kudos

Hi Uday,

but the original post wasn't about an ALV table I think?

I don't believe there is a set column position method for standard WDA tables - not ALV tables.

Please do let me know if there is!

Cheers,

Chris

uday_gubbala2
Active Contributor
0 Kudos

Hi Chris,

Sorry it was a slip from my end. Guess I need to read the threads a bit more carefully... But I do however have a workaround even for this!

You can set the "fixedPosition" property for the desired column to "left" to have it as the 1st column of your table. But you need to keep 1 thing in mind... If you have another column within the table having its "fixedPosition" property set to "left" then this would influence the final output. Say your table has col1, col2, col3 & col4. You have set the "fixedPosition" property to left for col2 & col4 then the final table output would be: col2, col4, col1, col3

Regards,

Uday