cancel
Showing results for 
Search instead for 
Did you mean: 

Capture the rows selected in a multiselect table view (BSP)

Former Member
0 Kudos

Hi,

My requirement is:

I have a table view in which I can select multiple rows.

I will be selecting some rows, and pressing a button.

Functionality of button is written in Javascript, to open a popup window.

But how will I capture which all rows were selected ?

Should I use a Java code or ABAP code ?

And where should I put that code ?

I tried calling the method cl_hrrcf_iterator=>get_tv_attr in the Javascript of the button. But it doesnt work. But if its in DO_HANDLE_DATA it works. Why is it like that ?

Is it possible in BSP, to use the function htmlbevent.obj.getSelectedRows() ? If so, how should the code be ?

Could you please tell me some of the possible solutions.

Would definitely appreciate quick replies.

Thanks,

Nisha Vengal.

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member184111
Active Contributor
0 Kudos

Hi Nisha,

You can do as follows:

data: begin of st_row_idx,
		row_idx type i,
      end of st_row_idx.
data: itab_row_idx type table of st_row_idx.
data: wa_row_idx like line of it_row_idx.

IF event IS NOT INITIAL AND event->event_name = htmlb_events=>tableview.
  tv_event ?= event.

  CASE event->event_server_name.
    WHEN 'MyEventRowSelection'.

	wa_row_idx-row_idx = tv_event->selectedrowindex .

	READ TABLE itab_row_idx INTO wa_row_idx WITH KEY row_idx = wa_row_idx-row_idx.

	IF sy-subrc = 4., <---if the current selected row is not already in itab_row_idx
	APPEND wa_row_idx TO itab_row_idx.
	endif.

ENDCASE.
ENDIF.

Then you have indices of all selected rows in table itab_row_idx .

Hope it helps,

Anubhav.

Former Member
0 Kudos

Hi Anubhav,

Could you please tell me where I should put that code?

In DO_REQUEST ?

Thanks,

Nisha Vengal.

former_member184111
Active Contributor
0 Kudos

Hi,

No, put that code in DO_HANDLE_EVENT .

For this code to work properly , you must declare ITAB_ROW_IDX in page attributes of view and make the application stateful or define ITAB_ROW_IDX as class attribute

because each time the page is refreshed itab_row_idx will be initialised , so to retain its contents we need to do one of the above things....

Hope its clear to you.

Regards,

Anubhav.

Former Member
0 Kudos

Hi Nisha,

You can have the ABAP code itself. I had also faced with then same issue. Use the below piece of code form your requirements.

 In *IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_ROW_START*
*  Data : M_ROW_REF type <Structure type>
 *m_row_ref ?= p_row_data_ref*

In *IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START*
* DATA : CHK TYPE FLAG
*case p_column_key.*
   when ' <Column Name>'.*
     CHK = m_row_ref-><Column Name>.*
      p_replacement_bee = CL_HTMLB_CHECKBOX=>FACTORY(
                            id                = p_cell_id
                          checked         = CHK ).

In *Do Request* 
Data : loc_table_event type ref to cl_htmlb_event_tableview
call method cl_hrrcf_iterator=>get_tv_attr
    exporting
      p_tv_id               = '<Tabe View ID'
      p_component_id        = me->component_id
      po_request            = me->request
    importing
      po_tv_event           = loc_table_event. 

The above methods are used to get the values which are selected in the table view and operated further.

Reward points if useful.

Regards,

Gokul.N

former_member184111
Active Contributor
0 Kudos

Hi,

Check the method GET_ROWS_SELECTED of class CL_HTMLB_EVENT_TABLEVIEW ..

Regards,

Anubhav.

Former Member
0 Kudos

Hi Anubhav,

Thanks for replying.

The method GET_ROWS_SELECTED of class CL_HTMLB_EVENT_TABLEVIEW is being called in the method get_tv_attr of class cl_hrrcf_iterator.

But it didnt work for me.

Thanks,

Nisha Vengal.