on 08-22-2007 3:18 PM
Hello Experts,
I have used toolbarbuttonchoice and created the dropdown list of the buttons dynamically. now when any of the button is clicked i need to get the reference of the button to call appropriate code in the action, but i am unable to get the either the reference or index of the clicked button.
Please help.
Regards,
Kinshuk
Have a look on the map_on_action method. You can dynamically add a parameter which will be transfered to the action handler:
CLEAR lt_parameters.
<b>INSERT INITIAL LINE INTO TABLE lt_parameters ASSIGNING <param1>.
<param1>-name = 'CE'.
<param1>-type = 'r'.
<param1>-object = lr_subelement.</b>
lr_choice = cl_wd_menu_action_item=>new_menu_action_item( ).
lr_choice->set_text( ls_auth-text ).
<b> lr_choice->map_on_action( lt_parameters ).</b>
In my case I transfer a context_element, but you can also use an integer which can be used in case in the action handler. In the action handler i just defined the import parameter CE type ref to if_wd_context_element.
lt_parameters is typer if_wd_event=>parameters.
Cheers,
Sascha
Message was edited by:
Sascha Dingeldey
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sascha,
My code goes this way
data:
lr_btn_ch type ref to if_wd_view_element,
lr_toolbar_btn_choice type ref to cl_wd_toolbar_btn_choice,
lr_row_data type ref to cl_wd_row_data,
item type string,
action type string.
CALL METHOD view->get_element
EXPORTING
id = 'BTNCH' " button choice Element in layout
receiving
element = lr_btn_ch
.
lr_toolbar_btn_choice ?= lr_btn_ch.
DATA: lt_items type string_table,
lt_actions type string_table.
loop at lt_dyntab into ls_dyntab.
append ls_dyntab-name to lt_items.
append 'ONBTNCH' to lt_actions.
endloop.
i get the data in the table lt_dyntab from API not in context
loop at Lt_items into item.
read table Lt_actions index sy-tabix into action.
create_choice_item( i_toolbar_btn_choice = lr_toolbar_btn_choice i_item = item i_action = action i_view = VIEW ).
endloop.
create_choice_item creates the menu item for the button choice..
My question is where should i call the map_on_action method. and how do i retrieve the index or reference in ONBTNCH method.
please elaborate.
Regards,
Kinshuk
Hi Kinshuk.
You would call it in the create_choice_item method.
I assume each item calls the same action. Then just transfer an ID or the current loop index to your method.
In the method additionally call:
lr_choice_item->map_on_action( lt_parameters ).
Have a llok at component WDR_TESt_p00009 in V1 in method wddomodifyview.
To fill lt_parameters you would do something like this:
INSERT INITIAL LINE INTO TABLE lt_parameters ASSIGNING <param1>.
<param1>-name = 'ID'.
<param1>-type = 'g'.
<param1>-value = A ID OR AN INDEX
Then in you action BTNCH add the import parameter ID type string or i.
Now you can check out which item has been clicked.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.