on 10-09-2008 8:32 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.