cancel
Showing results for 
Search instead for 
Did you mean: 

Buttons in the table

Former Member
0 Kudos

Hi Sap Gurus,

I have a normal table with buttons in one column. After clicking a button I need to have an button id and the line of the table witch includes this button. The button id is in the parameter of Event Handler, but I don't know how to check the line number. I found some information on SDN that I can use lead selection. But this is not a perfect solution, because befor clicking the button I need to mark a line in which this button exists. Do you have a better solution?

Best regards

Roman Byrdziak

Accepted Solutions (1)

Accepted Solutions (1)

abhimanyu_lagishetti7
Active Contributor
0 Kudos

data: lr_element type ref to if_wd_context_element.

data: lv_index type i.

lr_element = WDEVENT->GET_CONTEXT_ELEMENT( 'CONTEXT_ELEMENT' ).

lv_index = lr_element->get_index( ).

lv_index will have the rown number.

Former Member
0 Kudos

Abhimanyu Lagishetti and Saurav Mago yours code will always return the first line, because this returns only the marked line (lead selection) not the line with relevant button.

If I mark the line (set the lead selection) I will receive the proper results, the thing is that I want do this only via clicking on the button.

Former Member
0 Kudos

Hi Roman ..

I tried your senario in my st=sytem its working fine for me ..

Write this code in the on action of the button

DATA lo_nd_scarr TYPE REF TO if_wd_context_node.
  DATA lo_el_scarr TYPE REF TO if_wd_context_element.
  DATA ls_scarr TYPE wd_this->Element_scarr.
* navigate from <CONTEXT> to <SCARR> via lead selection
  lo_nd_scarr = wd_context->get_child_node( name = wd_this->wdctx_scarr ).
CALL METHOD wdevent->get_context_element
    EXPORTING
      name  = 'CONTEXT_ELEMENT'
    RECEIVING
      value = lo_el_scarr.  " getting the clicked line 

CALL METHOD LO_ND_SCARR->SET_LEAD_SELECTION
  EXPORTING
    ELEMENT = lo_el_scarr     " setting the Lead for the cliked button line 
    .
* get all declared attributes
  lo_el_scarr->get_static_attributes(
    IMPORTING
      static_attributes = ls_scarr ).

Regards

Chinnaiya P

Answers (2)

Answers (2)

Former Member
0 Kudos

Buttons included inside column of a table will Make UI design messy and unclean

I would advice to create a single button on table toolbar and on select of row and pressing of that button do your required action.

Regards

Manas Dua

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>

> Buttons included inside column of a table will Make UI design messy and unclean

>

> I would advice to create a single button on table toolbar and on select of row and pressing of that button do your required action.

> Regards

> Manas Dua

Of course this is a matter of design opinion, but I'm not sure I completely agree. I think buttons should be used sparingly within tables, but I have seen use cases where the button(s) within the table make for a simplier UI. It "feels" like one less click if the user doesn't have to set the lead selection on a row and then hit a button in the toolbar. Also if your table is multi-selection, but you need the action only triggered off a single row, this can be a clearer approach.

Former Member
0 Kudos

Refer this :

data: lr_element type ref to if_wd_context_element,
          lv_index type i.
 
  lr_element = wdevent->get_context_element( name = 'CONTEXT_ELEMENT'  ).
  lv_index = lr_element->get_index( ).