Skip to Content
author's profile photo Former Member
Former Member

TableView and selected row

Hi forum,

I've read a couple of threads and all the weblogs regarding tableviews and this problem but I didn't manage to come up with a solution for this...

Maybe somebody in here can help me out. 😊

My app: BSP using MVC-pattern. Three controllers, with C3 being child of C2 and C2 child of C1. Each has its own view.

C2 has a Tableview in mode singleselect. When a row gets selected the third controller is activated and renders a form with some inputfields and two buttons for saving and cancelling.

When cancel is pressed the third controller is set inactive and is not rendered. The problem is that the tableview keeps the selected row. For the app this is no big deal, because clicking the row again or clicking another row still fires the event, everything is working fine. But the user might get a little confused because the row is still shown as selected and becomes 'unselected' if clicked again, but because the event is fired C3 is rendered again.

I tried to clear the selectedrow attribute of the tableview in the do_request of the second controller depending on some other attribute.

  tvPU ?= CL_HTMLB_MANAGER=>GET_DATA( request = request
                                      name = 'tableView'
                                      id = 'test' ).
  CLEAR tvPU->data->selectedrowkey.
  CLEAR tvPU->data->selectedrowindex.

But the tvPU->data->... fields are all empty, so nothing to clear here.

Ok, I should admit that the design of the application may be a little confusing and not the best. Maybe I should think about changing that in order to avoid problems like the one described above.

Some suggestions for me?



Add comment
10|10000 characters needed characters exceeded

1 Answer

  • Best Answer
    Posted on Aug 17, 2004 at 08:40 PM

    Hallo Alexander,

    I am not sure that I extracted the question correctly. Effective you are asking for a way to have the selected row be forgotten?

    When you do a get_data call, you effectively have an instance of the renderer class, onto which data is instantiated from the incoming request. This reference is lot 14 milliseconds later when you leave the method and the local data: statement on the stack gets out of scope. ABAP comes and cleans up the garbage.

    So what you actually want to influence, is the new renderer instance that will render out your table. And this is the <htmlb:tableView> sequence that causes a new instance to be created. If you do not set specific parameters, they are restored from the request. One such is the selected row values. Just set both (selectedRowIndex & selectedRowKey) to empty. Should work, not tested.


    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks Brian,

      seems as the solution was much simpler than I thought. I simply overlooked the two attributes of the TableView.

      It now works the way it is supposed to.



      P.S.: Rewardpoints are on the way to yours... 😊