cancel
Showing results for 
Search instead for 
Did you mean: 

New CTable selection property

Former Member
0 Kudos

Hello Experts,

I have migrated to the new CTable in WD ABAP. I realise that there is no lead selection available so i used the selected elements to retrieve the selection.

Now I wonder, incase there is a selected row and i want to refresh the table and set the same selected row back as selection, i fail as i need the index of the row and then set based on index.

Could you please help?

Thanks in Advance,

Piyush

Accepted Solutions (1)

Accepted Solutions (1)

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Just try to get the index before refresh and set it after refresh.

   data lv_index type i.
CALL METHOD lo_nd_empdetails->get_lead_selection_index
  receiving
    index  = lv_index
    .

CALL METHOD lo_nd_empdetails->set_lead_selection_index
  EXPORTING
    index  = lv_index
    .

Former Member
0 Kudos

Hello Jayanthi,

Thank you for your reply.

The problem here is, when i try to retrieve the index through

CALL METHOD lo_nd_empdetails->get_lead_selection_index

  receiving

    index  = lv_index

I get the value 2- . It does not return the index of selected row. May be this is again the problem with unsupport of Lead Selection in CTABLE element.

Can yo usuggest anything here?

Thanks and Regards,

Piyush

chengalarayulu
Active Contributor
0 Kudos

Piyush,

can you try the below one.

data: lo_element type ref to if_wd_context_element.

lo_element = lo_nd_empdetails->get_context_element( name = 'CONTEXT_ELEMENT' ).

lv_index = lo_element->get_index( ).

Now lv_index holds selected element index.

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

As suggested, you can use get_index method of if_wd_context_element.

   DATA lo_ndTYPE REF TO if_wd_context_node.

    data lo_element type ref to if_wd_context_element.

  lo_nd = wd_context->get_child_node( name = wd_this->wdctx_node).

  data lv_index type i.

* @TODO handle non existant child
IF lo_nd IS NOT INITIAL.
* get element via lead selection
  lo_element = lo_nd->get_element( ).
ENDIF.

IF lo_element IS NOT INITIAL.

CALL METHOD lo_element->get_index
  receiving
    my_index = lv_index
    .
ENDIF.

And then use set_lead_selection_index.

Former Member
0 Kudos

Hi Chengalarayulu,

I tried the code but there is no method GET_CONTEXT_ELEMENT in interface IF_WD_CONTEXT_NODE.

Can you suggest the alternative.

Also if i have the table, and an action is performed on particular row ( Click of button ), how can i realise the row for which the button was clicked?

Thanks in advance

Piyush

chengalarayulu
Active Contributor
0 Kudos

Sorry piyush, the method get_context_element does not exists under node.. please refer below corrected code.

lo_element = wdevent->get_context_element( name = 'CONTEXT_ELEMENT' ).

Answers (0)