-4

sapui5 的新手,我正在尝试对现有开发进行更改并在此 UI 中添加另一个按钮。

这是我的编码,我正在尝试将 oAssetBtn2 添加到 UI,其他按钮已经可以使用?

目前,我收到错误:AppController.js:2283 自定义代码错误:错误:添加具有重复 id 'assetBtn-Custom2' 的元素错误:错误:添加具有重复 id 'assetBtn-Custom2' 的元素

       ASSETCREATE = function() {
       var oAssetBtn2  = sap.ui.getCore().byId('assetBtn-Custom2');
       };

      ASSETCREATE.prototype.CUSTOM_POST_EXIT = function(methodName, view, 
      controller,methodSignature, dialog) {
        if (view == 'accountLineDetails') {
           sap.ui.getCore().byId('CategoryListDetAS').setProperty('enabled',false);
       this.accounting = 
       sap.ui.getCore().byId("accAssignment").getController().accounting;
       var oFormModel = this.accounting.callMethod("_getFormModel");
       var oModel = oFormModel.oData ;
    jQuery.sap.require("sap.ui.commons.MessageBox");
    var oBtnLayout  = 
    sap.ui.getCore().byId(sap.ui.getCore().byId('saveBtn').getParent().getId());
    var oAssetBtn   = sap.ui.getCore().byId('assetBtn-Custom');
    // Add the "Create Multiple Asset" button in the footer layout
    jQuery.sap.require("sap.ui.commons.MessageBox");
    var oBtnLayout2 = 
  sap.ui.getCore().byId(sap.ui.getCore().byId('cancelBtn').getParent().getId());
    var oAssetBtn2  = sap.ui.getCore().byId('assetBtn-Custom2');
        <%
        data: lv_langu type sy-langu.
  lv_langu = sy-langu.
%>
    var lv_language = "" ;
    var lv_text = "";
    var lv_multiple_txt = "";
    if( lv_language == "F" ){
       lv_text = "Créer Immo";
       lv_multiple_txt = "Créer Plusieurs Actifs";
      }
      else{
       lv_text = "Create Asset";
       lv_multiple_txt = "Create Multiple Assets";
      }
        var oAssetBtn2 = new sap.ui.commons.Button({
        id   : "assetBtn-Custom2",
        text : lv_multiple_txt,
        tooltip : Appcc.getText("Create many Assets")
        });
    if (!oAssetBtn) {
        var oAssetBtn = new sap.ui.commons.Button({
        id   : "assetBtn-Custom",
        text : lv_text,
        tooltip : Appcc.getText("Creates an Asset")
      });

感谢各位程序员!

在 Chrome 中查看错误: err

4

1 回答 1

1

要将按钮添加到您的应用程序,您必须将其绑定到您的视图或查看页面。[Layout/view name].addContent([button name]); 在你的情况下, 你将如何做到这一点oBtnLayout2.addContent(oAssetBtn2);

于 2017-12-13T11:48:04.920 回答