cancel
Showing results for 
Search instead for 
Did you mean: 

item selection between two lists

Carola1
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello

how can I realize a screen with two itemlists and inbetween these two lists I need a button which moves one or more item from list1 to list2 and a second button which removes one or more item from list2 back to list one. I've seen something like this for ALV settings in an ALV demo video.

Is there any WDA example, where I can see the ui elements, that I need, including event handling etc ?

Thanks and regards.

Carola

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Also, your screen layout will be a grid layout with colcount = 3, so that the two tables and the button in between all come in the same line.

Answers (4)

Answers (4)

Carola1
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Sascha,

which Ui element did you use ? Itemlistbox?

How do I get the selected entries ? (multiple selection possible )

Kind regards.

Carola

Former Member
0 Kudos

Hi Carola,

You can use a normal table itself. It is important that the selection property of your context is set to 0..n if you want multiple selection. Else it will dump.

You can get the selected elements as node->get_selected_elements() that will return you a set of elements.

Regards

Nithya

Former Member
0 Kudos

Hi Carola.

Yeah I used tables (no ALV).

Cheers,

Sascha

Former Member
0 Kudos

Hi Carola.

Are both lists of the same structure?

Then it will be very easy. Just create two node with this structure and buind it to the tables. Create the buttons and add actions to the buttons.

In the action gat the referebnce of the corresponding node and use

get_element( ) if only one element can be selected

or

get_elements( ) if multi selection is allowed.

Then get the reference to the other node and use bind_elements( ) to append the elements.

Afterwards remove the elements from the first node:

here i move user profiles from one table to another.


METHOD onactionadd_profiles .
  DATA:
        lr_node_user_profiles        TYPE REF TO if_wd_context_node,
        lr_node_profiles             TYPE REF TO if_wd_context_node,
        lr_elem_profiles             TYPE REF TO if_wd_context_element.

  data:
        lt_sel_profiles           type WDR_CONTEXT_ELEMENT_SET,
        lt_profiles               type table of zsalsa_profile.

  data:
        ls_profile                type zsalsa_profile.


  lr_node_profiles = wd_context->get_child_node( name = wd_this->wdctx_profiles ).
  lr_node_user_profiles = wd_context->get_child_node( name = wd_this->wdctx_user_profiles ).

* get all selected profiles
  lt_sel_profiles = lr_node_profiles->get_selected_elements( abap_true ).

* build profile table and remove selected profiles from node
  loop at lt_sel_profiles into lr_elem_profiles.
    lr_elem_profiles->get_static_attributes(
      importing
        static_attributes = ls_profile
    ).
    lr_node_profiles->remove_element( lr_elem_profiles ).
    append ls_profile to lt_profiles.
  endloop.

* add selected profiles to user profiles.
  lr_node_user_profiles->bind_table(
    NEW_ITEMS = lt_profiles
    SET_INITIAL_ELEMENTS = abap_false
  ).

endmethod.

Former Member
0 Kudos

hi,

may be you can have a look at the following web dyn pro component : WDR_TEST_UI_ELEMENTS

it contains many examples of using various UI elements

Former Member
0 Kudos

Create two context nodes, one to bind to the list of elements and the other to bind the list of selected elements. Have two internal tables and bind them to the context nodes. Now have a button "Move" or something in between the lists. In the OnAction of the button, in your event handler, remove the selected entry from the first table and append it to the internal table of the second table. Do a bind_elements on both nodes after that and the values will be refreshed.

In the event handler, you can get the lead selection index of the first node, which will give you the row that has been selected. Delete this row from the first internal table and append it to the second internal table. Hope I was clear enough.

Regards,

Nithya