您的位置:首页 > 其它

ALV参考文档(十二)

2007-12-12 17:06 288 查看
覆盖标准功能
Alv grid控件还可以覆盖标准功能。使用两个事件可以达到这个目的:before_user_command和set_user_command。Before_user_command使用户可以实现自定义的功能,set_user_command用来把alv grid的user command设为空。
FORM handle_before_user_command.
CASE e_ucomm.
WHEN ‘&INFO’.
CALL FUNCTION ‘ZSFLIGHT_PROG_INFO’.
CALL METHOD gr_alvgrid->set_user_command
I_ucomm = space.
ENDCASE.
ENDFORM.
快捷菜单
跟快捷菜单相关的事件是context_menu_request。当右键单击alv grid的区域时就会触发快捷菜单事件。在这个方法里可以在快捷菜单中添加行。通过方法GET_SELECTED…来得到右键所点击的位置。给右键菜单中添加功能码跟为标准工具栏添加功能码的过程一样。
FORM handle_context_menu_request USING i_object TYPE REF TO cl_ctmenu.
*-- here you can add some logic to retrieve what is clicked and decide what to add to the
*--text menu
CALL METHOD i_object->add_function
EXPORTING fcode = ‘CREA’
Text = ‘Creat booking’.
ENDFORM.
可以通过方法add_separator添加separator, add_menu添加menu,add_submenu添加submenu。
可以通过方法disable_functions使菜单的某些功能码失效,enable_functions使其生效,hide_functions隐藏功能,display_functions显示功能。给这些方法的fcodes参数赋值来实现这些功能。这些都跟类CL_CTMENU有关,因为菜单会实例化这个类。
DATA lt_fcodes TYPE ui_functions.
Clear lt_fcodes.
APPEND cl_gui_alv_grid=>mc_fc_col_optimize TO lt_fcodes.
APPEND ‘CREA’ TO lt_fcodes.
CALL METHOD e_object->disable_functions
EXPORTING fcodes = lt_fcodes.
关于打印
有几个关于打印的事件。只需在这些事件里写上要输出的内容即可。下面是这些事件的列表。
Print_end_of_list
Define output text to be printed at the end of the entire list
Print_top_of_list
Define output text to be printed at the begin of the entire list
Print_end_of_page
Define output text to be printed at the end of each page
Print_top_of_page
Define output text to be printed at the beginning of each page
要使用这些事件,首先要在句柄类中添加一句柄事件。
METHOD handle_print_top_of_list
FOR EVENT print_top_of_list OF cl_gui_alv_grid.
然后再本地类中实现这些方法。
METHOD handle_print_top_of_list.
WRITE: ‘Flights Made On’,sy-datum.
ENDMETHOD.
并把这个方法注册为句柄
SET HANDLER gr_event_handler->handle_print_top_of_list FOR gr_alv_grid.
可以在打印预览中测试这些方法。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: