cancel
Showing results for 
Search instead for 
Did you mean: 

add check box column to the table

Former Member
0 Kudos

Hi,

I want to add a check box column in the table, so that the items in the table can be selected (multi-selection) by clicking the check box before each line item. How can I implement it?

View Entire Topic
Former Member
0 Kudos

Hi, Vishal

thanks a lot. but where should I put these code?

Best regards

Fan

uday_gubbala2
Active Contributor
0 Kudos

Hi Fan,

Dont go by Vishal's coding. He has given you the coding for implementing checkbox within an ALV. Its not for the normal table.

Regards,

Uday

vishalc_kava
Explorer
0 Kudos

Hello Fan,

For adding the check box in normal table, you need to create Table UI Element under table UI element, first add column, under column UI Element add checkbox UI Element. There is no progrmamming required for adding checkbox if this is a normal table.

My previous reply with source code was for adding check box in ALV Table.

Regards

Vishal.

uday_gubbala2
Active Contributor
0 Kudos

Hi Fan,

You can try do it in 2 ways: statically & dynamically.

I will explain both of the ways to you. Suppose you have bound your table to a context node by name SFLIGHT. It contains CARRID, CONNID, FLDATE, PRICE & an attribute by name CHECK of type WDY_BOOLEAN.

Static Method:

When you right click on your table & say "Create Binding" you select the context node as SFLIGHT & then you get the option to specify the Cell editor of the various table columns. Now go to your column CHECK and select the cell editor as "Checkbox" & name of property to be bound as "Checked". Now this would result in the column CHECK being displayed as a checkbox to you. Also the checked/unchecked values go and get stored in the boolean attribute CHECK that you had created at context level.

Dynamic Method:

Whenever you are working with dynamic ui modification you need to put your coding inside the WDDOMODIFYVIEW method. You need to basically perform the below steps to realise your functionality:

1) You need to first get the reference of the table element.

2) You then use this reference to get the reference of the desired column by specifying the column index. 3) 3) You then create an object of type checkbox & then embed it within the cell editor of the table column

Below is the coding from the method:

method WDDOMODIFYVIEW .
  data: lr_table type ref to cl_wd_table,
        lr_column type ref to cl_wd_table_column,
        lr_check  type ref to cl_wd_checkbox.

  check first_time = abap_true.

  lr_table ?= view->get_element( id = 'TABLE' ).

  lr_column ?= lr_table->get_grouped_column( id = 'TABLE_CHECK' ).

  lr_check = cl_wd_checkbox=>new_checkbox( bind_checked = 'SFLIGHT.CHECK' ).

  lr_column->SET_TABLE_CELL_EDITOR( THE_TABLE_CELL_EDITOR = lr_check ).
endmethod.

Regards,

Uday