cancel
Showing results for 
Search instead for 
Did you mean: 

Finding index of row , for which event is to be trigered.

former_member184111
Active Contributor
0 Kudos

Hi All,

We have a delete icon in one column of a tableview.

As soon as the row is selected,the icon becomes visible.Below is the code for it:

WHEN 'ACTIONS'.
      IF p_edit_mode IS NOT INITIAL.
DATA col_image TYPE REF TO cl_htmlb_image.
col_image = c l _ h t m l b _ i m a g e = > f a c t  o r y (   i d   =   p_ c e l l _ i d   s rc   =   ' . . / z _ e c a r _n e w u i / d e l e t e _ i c o n . j p g '   
 a l t   =   ' d e l e t e   r o w '   on c l ic k  =  ' d e l e t e ' ) . 
   p_ r e p l a c e m e n t _ b e e   =   c o l _ i m a g e . 
   E N D I F .

Code in OnInputProcessing:

IF event IS NOT INITIAL AND event->event_name = htmlb_events=>image .
*  tv_event ?= event .
  CASE event->event_server_name.

**Delete icon in tableview.

    WHEN 'delete'.
      DATA: cell_id_del(20).

      DATA: total_rows TYPE i.
      DATA: BEGIN OF wa_matnr,
              matnr TYPE bbp_ws_oci_item_s-matnr,
            END OF wa_matnr.
      DATA: it_matnr LIKE TABLE OF wa_matnr.

*      GET PARAMETER ID cell_id_del  FIELD cell_id_del.
      
      LOOP AT itab_row_idx INTO wa_row_idx.
        READ TABLE new_item INTO wa_item INDEX wa_row_idx-row_idx.
        wa_matnr-matnr = wa_item-matnr.
        APPEND wa_matnr TO it_matnr.
      ENDLOOP.

    


      LOOP AT it_matnr INTO wa_matnr.
        DELETE new_item WHERE matnr = wa_matnr-matnr.
      ENDLOOP.

      DESCRIBE TABLE new_item LINES total_rows.
      cl_htmlb_manager=>check_tableview_all_rows(
      rowcount = total_rows
      request = request
      id = 'mat_final'
      check = ' '
      ) .
ENDIF.

Now suppose there are 5 rows in the tableview,user selects first three rows ,so all three rows are editable now and delete icon is visible for these rows .Now if the user click delete icon of second row, how can i find out that delete icon on second row is pressed?

Thanks,

Anubhav.

Edited by: Anubhav Jain on Oct 9, 2008 10:47 AM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

IF you have a reference to the interface if_htmlb_data in the DO_HANDLE_EVENT, all the values should be in the reference.

The value would be in either of these variables.

EVENT_SERVER_NAME

EVENT_ID

-Aman

former_member184111
Active Contributor
0 Kudos

Hi Amandeep,

Found the ID of row for which event is trigered in EVENT->EVENT_ID

where

event             TYPE REF TO if_htmlb_data.

Thanks a lot.

Vijay and Michale thanks to you too for the inputs.

Anubhav.

Answers (2)

Answers (2)

former_member188685
Active Contributor
0 Kudos

you can use the class CL_HRRCF_ITERATOR method GET_TV_ATTR , and you can get the event and index of the row clicked. I managed with this in one of my application.

former_member184111
Active Contributor
0 Kudos

Hi Vijay,

I am developing these applications on SRM , so i guess HR related FMs are not available...let me check and get back tomorrow....

Thanks,

Anubhav.

former_member188685
Active Contributor
0 Kudos

that is not HR related...? , it is Service class for Table view iterator. if you don't find it you create a method in your controller and call it inside do_request or inputprocessing . that class in not available in 4.7, i copied the logic into a controller method, it worked well for me.

former_member184111
Active Contributor
0 Kudos

Hi Vijay,

Thanks for the information , but it is not available in the system here.where can i find the logic to copy...and i am working with Page with flow logic.

Thanks,

Anubhav.

former_member188685
Active Contributor
0 Kudos

if you can access to ECC5.0 or ECC6.0 system you can get the logic. if you are doing in Page with flow Logic then you may have to add the method in the application class. if you don't have any application class inyour application then create one , add the method specified above, use all the importing/exporting parameters and logic.

if you still don't find it , here is the code

P_TV_ID	Importing	Type	STRING	                                                                      	Table view ID from layout
P_COMPONENT_ID	Importing	Type	STRING	                                                                      	ID of Controller (Attribut component_id)
PO_REQUEST	Importing	Type Ref To	IF_HTTP_REQUEST	                                                                      	HTTP Framework (iHTTP) HTTP Request
P_VISIBLE_FIRST_INDEX	Exporting	Type	STRING                                                                                
P_VISIBLE_FIRST_KEY	Exporting	Type	ANY                                                                                
P_SELECTED_INDEX	Exporting	Type	STRING                                                                                
PS_SELECTED_KEY	Exporting	Type	ANY                                                                                
PT_SELECTED_INDICES	Exporting	Type	INT4_TABLE	                                                                      	Standard Table of INT4
PT_SELECTED_KEYS	Exporting	Type	ANY TABLE                                                                                
PO_TV_EVENT	Exporting	Type Ref To	CL_HTMLB_EVENT_TABLEVIEW	                                                                      	<htmlb:tableView> Event Data
method get_tv_attr.

  data:
    lo_tableview type ref to cl_htmlb_tableview,
    lo_tv_event  type ref to cl_htmlb_event_tableview,
    lv_id        type        string.
  data: lt_selected_rows    type selectedrows,
        ls_selected_row     type selectedrow,
        lt_selected_keys    type string_table,
        lt_selected_indices type int4_table.

*-- Construct tableview id
  if not p_component_id is initial.
    concatenate p_component_id '_' p_tv_id into lv_id.
  else.
    lv_id = p_tv_id.
  endif.

* get tableview
  try.
      lo_tableview ?= cl_htmlb_manager=>get_data(
                          request = po_request
                          name    = 'tableView'
                          id      = lv_id ).
    catch cx_root.
*--   nothing happens
  endtry.

* get tableview event data
  check lo_tableview is bound.
  lo_tv_event = lo_tableview->data.
  check lo_tv_event is bound.
  po_tv_event = lo_tv_event.

  clear: p_visible_first_key, p_visible_first_index,
         p_selected_index, ps_selected_key,
         pt_selected_indices[], pt_selected_keys[].

  call method lo_tv_event->get_rows_selected
    receiving
      selected_rows = lt_selected_rows.

  loop at lt_selected_rows into ls_selected_row.
    append ls_selected_row-index to lt_selected_indices.
    append ls_selected_row-key   to lt_selected_keys.
  endloop.

  sort: lt_selected_indices, lt_selected_keys.
  delete adjacent duplicates from lt_selected_indices.
  delete adjacent duplicates from lt_selected_keys.


  p_visible_first_index = lo_tv_event->visiblefirstrowindex.
  p_visible_first_key   = lo_tv_event->visiblefirstrowkey.
  p_selected_index      = lo_tv_event->selectedrowindex.
  if lo_tv_event->selectedrowindex <> 0.
    ps_selected_key       = lo_tv_event->selectedrowkey.
  endif.
*  pt_selected_indices[] = lo_tv_event->prevselectedrowindextable[].
*  pt_selected_keys[]    = lo_tv_event->prevselectedrowkeytable[].
  pt_selected_indices[] = lt_selected_indices[].
  pt_selected_keys[]    = lt_selected_keys[].

endmethod.

Former Member
0 Kudos

How did you implement the delete icons? Using a table view iterator??? Maybe you can add a unique ID to each icon, so that you can get the row number from the specific icon in the oninputprocessing event (when you get the ID of the component which triggered the oninputprocess event).

former_member184111
Active Contributor
0 Kudos

Hi Michael,

Can you please elaborate on how to add a unique ID to every icon and how to read it in oninputprocessing?

A code snippet will be of great help.

Thanks,

Anubhav.