on 06-05-2013 7:06 PM
I have an itemlistbox which I populate from a table. It's set to multiselect. I can pick and save the selections to a table with no problems. What I can't seem to figure out is how to get the itemlistbox to set the index(s) based on the data. When the itemlistbox loads nothing is selected. How can I pass a table of records to the itemlistbox so that they appear selected?
Hi,
Web Dynpro selection logic is stored in context objects - node and elements. You can use method set_selected of node or element to select specific items.
For example:
DATA: lr_node TYPE REF TO if_wd_context_node,
lt_rows TYPE wdr_context_element_set,
lr_elem TYPE REF TO if_wd_context_element.
lr_node = wd_context->get_child_node( name = 'TEST_NODE' ).
* Set first element selected
lr_node->set_selected( flag = 'X' index = 1 ).
* Set all elements selected looping at index
DO lr_node->get_element_count( ) TIMES.
lr_node->set_selected( flag = 'X' index = sy-index ).
ENDDO.
* Set all elements selected looping at element reference
lt_rows = lr_node->get_elements( ).
LOOP AT lt_rows INTO lr_elem.
lr_elem->set_selected( flag = 'X' ).
ENDLOOP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
In addition to what Sergey said you can also get the value of each attribute and set the flag depending on some business logic.
For example
LOOP AT lt_rows INTO lt_elem.
lt_elem->get_attribute(
EXPORTING name = 'ID' "Attribute name
IMPORTING value = l_value ). "Attribute variable
* You can put some business rules here to check for which rows you would like pre-select
IF l_value CS 'A'.
lt_elem->set_selected( flag = 'X').
ENDIF.
ENDLOOP.
Regards,
Karan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.