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

Posted ^ω^SAp傻X^o^

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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明细界面添加按钮的主要内容,如果未能解决你的问题,请参考以下文章

SAP UI5和CRM WebUI的View和Controller是如何绑定的

如何查看CRM WebUI,C4C和Hybris里的页面技术信息

CRM如何在新增模块中增加产品明细并从其他模块中取数

如何在地图片段 API v2 布局顶部添加按钮

CRM和C4C里的组织架构 - Organizational Structure

如何将按钮功能添加到片段中