on 2005 Aug 07 4:12 PM
New one:
In my tableview (multiselect), I need to access the SELECTED_TEXT attribute of the CL_PHTMLB_POPUPMENU class. This is because the mentioned attribute contains "Select all" or "Deselect all" depending on whether the user does just that in the tableview. However, I can't seem to access this attribute... what's needed?
trond
Are you just wanting to get the selected items?
I am on 640 SP12 and I just let the TableView control itself select the items (I don't respond to the CL_PHTML_POPUPMENU at all). When I need to get the list of the selected items I use the following code:
data: tv type ref to cl_htmlb_tableview,
table_event type ref to cl_htmlb_event_tableview.
tv ?= cl_htmlb_manager=>get_data( request = request
name = 'tableView'
id = 'dir_attach' ).
if tv is not initial.
table_event = tv->data.
endif.
model1->download_dir_event( sel_index = table_event->prevselectedrowindextable
runtime = runtime ).
But if you want to catch the Menu select directly you can. HTMLB_EVENT_EX throws the CL_PHTMLB_POPUPMENU class on the menu select event. You just need to cast it.
data: popup_event type ref to cl_phtmlb_popupmenu.
popup_event ?= htmlb_event_ex.
Both of these examples where model view controller. If you where in an old style page you would have to capture htmlb_event_Ex first:
data: htmlb_event_ex type ref to if_htmlb_data.
htmlb_event_ex = cl_htmlb_manager=>get_event_ex( request ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well, basically I want to know whether the user has Selected or Deselected all. The problem is firstly that the Select All/Deselect all action does not trigger an event (at least nothing that can be caught using the get_event method of the CL_HTMLB_MANAGER). So, I use the get_event_ex, which as you state gives me the cl_htmlb_popupmenu. BUT; the SELECTED_TEXT, which contains either "Select all" or "Deselect all" depending on the user's action, is out of reach. I can see the contents in the debugger, but cannot reference it in my code...
I've already tried to receive it into a type of CL_phtmlb_popupmenu, but it won't even compile:
popup_event type ref to cl_phtmlb_popupmenu.
popup_event = CL_HTMLB_MANAGER=>get_event_ex( request ).
gives
"The result type of the function method cannot be converted into the type of POPUP_EVENT"
However,
popup_event TYPE REF TO IF_HTMLB_DATA
works, but doesn't give anything but the IF_HTMLB_DATA interface attributes. The SELECTED_TEXT is still visible as an attribute of CL_PHTMLB_POPUPMENU in the debugger, but cannot be referenced in the code...
I'm on 620 SP 53... guess I'll have to check the OSS...
Nope it will work on your release. You are missing one very special little character:
Not:
popup_event = CL_HTMLB_MANAGER=>get_event_ex( request ).
Correct:
popup_event ?= CL_HTMLB_MANAGER=>get_event_ex( request ).
Notice the question mark. That isn't a typo. That is the casting operator. That allows you cast between similar objects (called Polymorphism). Since CL_PHTMLB_POPUPMENU contains the IF_HTMLB_DATA interface, you have able to cast into this more specific object instance.
I should note however that it probably isn't a good idea to cast from GET_EVENT_EX directly into CL_PHTMLB_POPUPMENU. If the event comes from a different element you could get a casting expection.
It is safer to cast into a general IF_HTMLB_DATA object, check the ID or TYPE of the event and then cast into the correct specific object instance.
User | Count |
---|---|
70 | |
10 | |
10 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.