Skip to Content

Select/unselect multiple rows in table without taking help of CTRL key

Scope: This document teaches you that how to select multiple rows in a table without taking help of CTRL key from key board. If you select the row which is already selected, that will be deselected.

steps to be followed:

1. Create a component

2. Create a node under the context of Component Controller like shown below

/wp-content/uploads/2012/06/01_108445.jpg

3. Map this node to your view.

4. Create a table UI element on view, maintain context mapping with above created node. please observe the below snap, which is inserted cell editor(LinkToAction) also while binding(Yellow marked).

/wp-content/uploads/2012/06/02_108455.jpg

5. Create an action for LinkToAction UI element on Table, which is going to use as multiple selector.(MULTI_SELECT)

/wp-content/uploads/2012/06/03_108456.jpg

/wp-content/uploads/2012/06/04_108457.jpg

6. Now come WDDOINIT method of View, and write the below code / Process your selection/model operations. And bind the value set to the table bound node(ND_TABLE).

    DATA lo_nd_nd_table TYPE REF TO if_wd_context_node.
  DATA lt_nd_table TYPE wd_this->elements_nd_table.

* navigate from <CONTEXT> to <ND_TABLE> via lead selection
  lo_nd_nd_table = wd_context->get_child_node( name = wd_this->wdctx_nd_table ).

  SELECT *
    FROM zhr_resume_det
    INTO CORRESPONDING FIELDS OF TABLE lt_nd_table UP TO 10 ROWS.

  lo_nd_nd_table->bind_table( new_items = lt_nd_table set_initial_elements = abap_true ).

7. Write the below code on MULTI_SELECT action.

    DATA lo_el_nd_table TYPE REF TO if_wd_context_element.

* get element via lead selection
  lo_el_nd_table = wdevent->get_context_element( name = ‘CONTEXT_ELEMENT’ ).

  IF lo_el_nd_table->is_selected( ) EQ abap_true.
    lo_el_nd_table->set_selected( flag = abap_false ).
  ELSE.
    lo_el_nd_table->set_selected( flag = abap_true ).
  ENDIF.

8. Now create an application, test. (Click on the link to select/deselect).

/wp-content/uploads/2012/06/06_108461.jpg

/wp-content/uploads/2012/06/05_108462.jpg

Note:- You can also implement same thing onSelect action of Table UI element.

1 Comment
You must be Logged on to comment or reply to a post.
  • Techies,

    Small Update on this Doc, in EHP5 onwards no need to create LinkToAction UI element, we can directly handle on event onLeadSelect

    🙂