现在的位置: 首页 > 综合 > 正文

alv tree 上下文菜单

2013年10月02日 ⁄ 综合 ⁄ 共 1516字 ⁄ 字号 评论关闭

在类声明里:

 METHODS handle_node_cm_req
      FOR EVENT node_context_menu_request OF cl_gui_alv_tree
      IMPORTING node_key menu.                                                        右键弹出上下文
    METHODS handle_node_cm_sel
      FOR EVENT node_context_menu_selected OF cl_gui_alv_tree
      IMPORTING node_key fcode sender.                                             删除数据

 

在类实现里:

 METHOD handle_node_cm_req.
    CALL METHOD menu->clear.
    CALL METHOD menu->add_function
      EXPORTING
        fcode = 'DEL_SUBTREE'
        text  = text-901.                                               "删除节点
  ENDMETHOD.                    "handle_node_cm_req

 

  METHOD handle_node_cm_sel.
    DATA l_rc TYPE c.
    CASE fcode.
      WHEN 'DEL_SUBTREE'.
        CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
          EXPORTING
            textline1      = 'Do you really want to delete'(902)
            textline2      = 'this node and all its subnodes?'(903)
            titel              = 'Confirmation'(904)
            cancel_display = ' '
          IMPORTING
            answer         = l_rc.
        IF l_rc EQ 'J'.
          CALL METHOD sender->delete_subtree
            EXPORTING
              i_node_key = node_key.
          CALL METHOD sender->frontend_update.
        ENDIF.
    ENDCASE.
  ENDMETHOD.                

 

在类事件注册中加入:

 l_event-eventid = cl_gui_column_tree=>eventid_node_context_menu_req.

  APPEND l_event TO lt_events.

  set handler l_event_receiver->handle_node_cm_req for g_alv_tree.
  set handler l_event_receiver->handle_node_cm_sel for g_alv_tree.

在PAI CASE ok_code中加入:

  WHEN OTHERS.
      CALL METHOD cl_gui_cfw=>dispatch.

  ENDCASE.

      CALL METHOD cl_gui_cfw=>flush.

 

抱歉!评论已关闭.