首页 > 代码库 > CRM WEB UI 04明细界面添加按钮

CRM WEB UI 04明细界面添加按钮

好了,这个是个人测试玩的,略风骚。。。请自行鉴阅

1.明细的组件控制器中增加全局控制属性字段:

技术分享

2.概览页中工具栏相关方法,重定义GET_BUTTONS

  METHOD IF_BSP_WD_TOOLBAR_CALLBACK~GET_BUTTONS.
    DATA:LV_LOCK   TYPE ABAP_BOOL VALUE ABAP_TRUE,
         LV_ENABLE TYPE ABAP_BOOL VALUE ABAP_FALSE.
    DATA:LR_COM   TYPE REF TO ZL_ZLYTEST0_BSPWDCOMPONE3_IMPL.
    DATA:RW_BUTTON TYPE CRMT_THTMLB_BUTTON_EXT.


    CALL METHOD SUPER->IF_BSP_WD_TOOLBAR_CALLBACK~GET_BUTTONS
      RECEIVING
        RT_BUTTONS = RT_BUTTONS.

    LR_COM ?= ME->COMP_CONTROLLER.
    CHECK LR_COM IS BOUND.
    IF LR_COM->DISPLAY = ABAP_TRUE.
      LV_ENABLE = ABAP_FALSE.
    ELSE.
      LV_ENABLE = ABAP_TRUE.
    ENDIF.


    RW_BUTTON-TYPE = CL_THTMLB_UTIL=>GC_ICON_SAVE.
    RW_BUTTON-ON_CLICK = SAVE.
    RW_BUTTON-PAGE_ID = ME->COMPONENT_ID.
    RW_BUTTON-ENABLED = LV_ENABLE.
    APPEND RW_BUTTON TO RT_BUTTONS.

    RW_BUTTON-TYPE = CL_THTMLB_UTIL=>GC_ICON_CANCEL.
    RW_BUTTON-ON_CLICK = CANCEL.
    RW_BUTTON-PAGE_ID = ME->COMPONENT_ID.
    RW_BUTTON-ENABLED = LV_ENABLE.
    APPEND RW_BUTTON TO RT_BUTTONS.

  ENDMETHOD.

3.概览页中工具栏相关方法,重定义GET_NUMBER_OF_VISIBLE_BUTTONS

  METHOD IF_BSP_WD_TOOLBAR_CALLBACK~GET_NUMBER_OF_VISIBLE_BUTTONS.
    RV_RESULT = 9.
  ENDMETHOD.

4.DETAIL视图的实现类中定义属性:

技术分享

 

5.DETAIL视图中,重定义DO_PREPARE_OUTPUT

    DATA:LS_BUTTON TYPE CRMT_THTMLB_BUTTON.
    CALL METHOD SUPER->DO_PREPARE_OUTPUT.

    REFRESH GT_BUTTON.
    CLEAR:LS_BUTTON.
    LS_BUTTON-TYPE = CL_THTMLB_UTIL=>GC_ICON_EDIT.
    LS_BUTTON-TEXT = CL_WD_UTILITIES=>GET_OTR_TEXT_BY_ALIAS( CRM_UIU_BU/EDIT ).
    LS_BUTTON-ENABLED = ABAP_TRUE."此处可酌情控制
    LS_BUTTON-ON_CLICK = EDIT.
    APPEND LS_BUTTON TO GT_BUTTON.
  ENDMETHOD.

6.修改DETAIL的htm页面:用本地的变量控制配置页

<%@page language="abap" %>
<%@extension name="thtmlb" prefix="thtmlb" %>
<%@extension name="chtmlb" prefix="chtmlb" %>
<%@extension name="bsp" prefix="bsp" %>
<%
data:LV_XML type STRING,
     LV_DISPLAYMODE type STRING.
     LV_DISPLAYMODE = CONTROLLER->VIEW_GROUP_CONTEXT->IS_VIEW_IN_DISPLAY_MODE( CONTROLLER ).
     %>
     <thtmlb:areaFrameSetter toolbarButtons = "<%= controller->gt_button %>"
                             maxButtonNumber = "4"
                             displayMode     = "<%= lv_displayMode %>"
                             />
<chtmlb:config mode = "RUNTIME"
               displayMode  = "<%= CONTROLLER->VIEW_DISPLAY %>" />

 7.创建DETAIL的事件处理器EDIT

  METHOD EH_ONEDIT.
    DATA:LR_COM   TYPE REF TO ZL_ZLYTEST0_BSPWDCOMPONE3_IMPL.


    LR_COM ?= ME->COMP_CONTROLLER.

    CHECK LR_COM IS BOUND.

    IF LR_COM->DISPLAY = ABAP_TRUE.
      LR_COM->DISPLAY = ABAP_FALSE.
      VIEW_DISPLAY = ABAP_FALSE.
    ELSE.
      LR_COM->DISPLAY = ABAP_TRUE.
      VIEW_DISPLAY = ABAP_TRUE.
    ENDIF.

  ENDMETHOD.

 

OK了

技术分享

 

CRM WEB UI 04明细界面添加按钮