cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple row selection for table element

Former Member
0 Kudos

Hi,

I have a requirement where I require to select multiple rows from a table element in a WD for abap application.

I have defined a node with cardinality and selection set to 1..n.

The contex node contains 4 fields : emp_name, pernr, manager and position.

The attributes of the table element for selectionmode is set to 'multi' and 'selectionchangebehaviour' is set to 'auto'.

I have defined an action on the 'onleadselection' event.

The code in this method also includes the statement 'lo_el_team_view->set_selected( EXPORTING flag = abap_true ).'

When I execute the application only 1 row is highlighted at any one time when I select it. You can select multiple rows by holding down the 'ctrl' key but I want to avoid having to do this. Is there anything I have missed out causing multiple row selections not to be all highlighted.

Thanks in advance for any assistance.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Jayanthi, I tried this but it has not worked. When I select a new row the current highlighted row is deselected.

Former Member
0 Kudos

Hi raj,

you can try the following code in the 'onleadselect' event of the table,

create one attribute ' Flag' of type WDY_BOOLEAN under the node which has been binded to the table.

DATA lo_nd_node_tab1 TYPE REF TO if_wd_context_node.

DATA lo_el_node_tab1 TYPE REF TO if_wd_context_element.

DATA lo_elements TYPE wdr_context_element_set.

DATA lo_ele_select_new TYPE REF TO if_wd_context_element.

DATA lv_deselect TYPE wdy_boolean.

DATA lv_flag TYPE wdy_boolean.

DATA lv_select TYPE wdy_boolean.

DATA lv_index TYPE i VALUE 0.

lo_nd_node_tab1 = wd_context->get_child_node( name = wd_this->wdctx_node_tab1 ).

get the current selected element

lo_ele_select_new = wdevent->get_context_element( name = 'NEW_ROW_ELEMENT' ).

CHECK lo_ele_select_new IS NOT INITIAL.

check whether it has been selected or not

CALL METHOD lo_ele_select_new->is_selected

RECEIVING

flag = lv_select.

lo_ele_select_new->get_attribute( EXPORTING name = 'FLAG' IMPORTING value = lv_deselect ).

check whether element has been previously selected or not,if not, set the flag to select it

IF lv_select IS NOT INITIAL AND lv_deselect IS INITIAL.

lo_ele_select_new->set_attribute( name = 'FLAG' value = 'X' ).

if selected currently and previously then set the flag as false,in order to delect it

ELSEIF lv_select IS NOT INITIAL AND lv_deselect IS NOT INITIAL..

lo_ele_select_new->set_attribute( name = 'FLAG' value = ' ' ).

ENDIF.

CALL METHOD lo_nd_node_tab1->get_elements

RECEIVING

set = lo_elements.

according to the falg, select and delect the elements

LOOP AT lo_elements INTO lo_el_node_tab1.

lo_el_node_tab1->get_attribute( EXPORTING name = 'FLAG' IMPORTING value = lv_flag ).

IF lv_flag = 'X'.

lo_el_node_tab1->set_selected( abap_true ).

lo_nd_node_tab1->set_lead_selection_index( lv_index ). * this statement deselects the lead selection index*

ELSE.

lo_el_node_tab1->set_selected( abap_false ).

lo_nd_node_tab1->set_lead_selection_index( lv_index ).

ENDIF.

ENDLOOP.

I hope this resolves your problem.

Thanks,

krishna

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Set the node cardinality to 0:n. IN tha teable properties, set selectionmode = multi.

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

You need to hold control while selecting multiple rows.

Edited by: Jayanthi Jayaraman on Dec 2, 2010 8:00 AM

Former Member
0 Kudos

Hallo Raj,

Do i understand correctly that you dont want to do a selection by user pressing 'ctrl' key but programmatically set_selection on the event handler of Lean Selection.

How do you do that ? You may have a error here.

Edited by: Baskaran Senthivel on Dec 2, 2010 12:19 PM