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.
关于打印
有几个关于打印的事件。只需在这些事件里写上要输出的内容即可。下面是这些事件的列表。
要使用这些事件,首先要在句柄类中添加一句柄事件。
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.
可以在打印预览中测试这些方法。
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.
可以在打印预览中测试这些方法。
相关文章推荐
- ALV参考文档 ( 14 ) - 表单修改内容处理
- ALV参考文档(VII)
- ALV参考文档 ( 7 ) -取出和设置滚动条状态
- ALV GRID的参考文档 ( 1 )
- ALV GRID的参考文档 ( 9 ) - 管理显示变式
- (十二)unity4.6学习Ugui中文文档-------参考-UGUI Interaction Components(上)
- ALV GRID参考文档 ( 2 ) - 通过CREATE OBJECT来实例化类
- ALV GRID参考文档 ( 10 )
- ALV GRID参考文档(十一)
- ALV GRID参考文档(十三)
- ALV参考文档(THE END)
- 整理后的ALV GRID的参考文档
- ALV参考文档 ( 12 ) - 覆盖标准功能
- ALV参考文档(VIII)
- ALV GRID参考文档(十)
- ALV GRID的参考文档 ( 5 ) - 打印调整
- ALV GRID参考文档 ( 13 ) - ALV控件中的内容可编辑
- ALV GRID的参考文档(I)
- Csharp编程指南+参考手册文档分享
- Django文档翻译:模型参考(Model Reference)