cancel
Showing results for 
Search instead for 
Did you mean: 

Getting tableview selectedrowindex from subcontroller

Former Member
0 Kudos

Hi experts,

I have a tableview created by one of my sub views.

Please see the following image link for my design:

http://img203.imageshack.us/img203/2298/subcontrollers6ub.gif

The view with the red border is the one displaying the iterator/tableview.

I need to get the selected row index in my main controller (<b>MAIN.DO</b>)

In my main controller's DO_HANDLE_EVENT, the following code works only IF the iterator resides in "Page1.htm".

The iterator is now located in Page1_Sub2.htm.


   WHEN 'getChange_exprep'.
      tbv ?= CL_HTMLB_MANAGER=>GET_DATA( request = request
                                         name    = 'tableView'
                                         id      = 'tbv_ExpRep' ).

      IF tbv IS NOT INITIAL.
        tbv_event = tbv->data.
        selectedRowIndex = tbv_event->SELECTEDROWINDEX.
        IF selectedRowIndex <> 0.
          DELETE model->AT_IUI_COSTASSIGNTRIP INDEX selectedRowIndex.
        ENDIF.
      ENDIF.

I can get a reference to my subcontroller from my main controller, but i don't know how that can help.

Any idea?

Message was edited by: Kevin Wong

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

I realized why I could my main controller could not get values of the tableview in the subcontroller.

I see that although I specify in my sub view the following:

<htmlb:tableView id = "tbv_ExpRep"

table = "//model/AT_IUI_TRIPLIST"

iterator = "<%= ATO_ITERATOR %>"

selectionMode = "SINGLESELECT"

/>

It still appends the sub controller ID to tableview ID making it something like

<i>id = "subcontrollerID_tbv_ExpRep"</i>

in the HTML code, that is why my main controller cold not find it.

This name appending doesn't seem to happen for tableviews at the main view level though.

0 Kudos

Hi Kevin!

Dispatch_input( ) needs the appended sub-controller-ids to determine the controller which is responsible for handling the events. Hence, at least the do_handle_event( ) of your sub-controller should be called! Try to debug the method (set a breakpoint directly at the beginning of the method). If the sub-do_handle_event( ) is not called, then try to look if the sub-controller is correctly assigned to your main-controller (check attribute 'm_subcontrollers' in debugger)! This shouldn't be the problem because you assigned a component id to the sub-controller in your <bsp:call>-tag ..

If do_handle_event( ) is called correctly, than you should change the id of the table in the coding you posted in your first message:


tbv ?= CL_HTMLB_MANAGER=>GET_DATA( 
  request = request
  name    = 'tableView'
  id      = 'subcontrollerid_tbv_ExpRep' ).

Then the attribute selectedrowindex should be available in tbv.

Best regards,

Georg

Message was edited by: Georg Lang

daniel_humberg
Contributor
0 Kudos

You can also get the id of any element of a subcontroller with


controller->get_id( )

So you can do it like this:


DATA lv_id TYPE string.
lv_id = me->get_id( 'tbv_ExpRep' ).
tbv ?= CL_HTMLB_MANAGER=>GET_DATA( 
  request = request
  name    = 'tableView'
  id      = lv_id ).

Former Member
0 Kudos

Hi Georg,

I'm trying your solution, but I am having problems triggering the sub controller's do_handle_event.

(My main controller has DISPATCH_INPUT( ))

It triggers my DO_HANDLE_EVENT in my main controller, but not in the subcontroller.

This button that is supposed to trigger this event is located above my tableview, not inside my tableview.

Both are located inside Page1_Sub2.htm.

<i>

Observation:

I don't know why but it seems to me that controls that are in the Page1_Sub2.htm automatically trigger the Main.do's event handler.

I notice in some cases where the sub-controller is the one that directly builds the control (whether it is a radiobutton etc) only then will the subcontroller's DO_HANDLE_EVENT be invoked.</i>

Where does my problem lie?

Message was edited by: Kevin Wong

Message was edited by: Kevin Wong

0 Kudos

Hi Kevin!

Have you tried to handle the tableview event in your sub-controller 'page1_sub2.do'? Here you could pass the selectedrowindex to your parent controller which is referenced by the attribute 'M_PARENT'.

You can pass the selectedrowindex by defining a reference variable to the class of your main controller and point to 'M_PARENT' (local_ref ?= m_parent). Now you can hand over the selectedrowindex by using your reference variable ..

Hope that helps ..

Best regards,

Georg