2016-08-16 50 views
-1

我正在使用sapui5面板,並且我允許展開,它會在工具欄「>」上顯示默認圖標,當我點擊它時,它會彈開,但我想在其上添加一些操作。sapui5-如何更改面板圖標點擊事件的默認操作?

這是面板,最後有一個圖標。 任何想法可以覆蓋功能,自定義功能,或者當我們點擊它時在該圖標上添加一些操作?

我的目的是,我想在面板崩潰之前添加警告消息,如果我點擊「是」確認,它可以崩潰,「否」它仍然是一樣的,什麼都不做。

Here are the image of panel and icon

回答

0

你試過attachExpandhttps://sapui5.hana.ondemand.com/docs/api/symbols/sap.m.Panel.html#attachExpand

我還是新來這個UI5:P

在這裏,我們去

 var panel = new sap.m.Panel("panel-1", { 
      headerText:"Test Panel", 
      expandable: true 
     }); 
     panel.setExpanded = function (bExpanded) { 
      if (bExpanded === this.getExpanded()) { 
       return this; 
      } 
      //may need to reset this later 
      this.setProperty("expanded", bExpanded, true); 
      if (!this.getExpandable()) { 
       return this; 
      } 

      //add custom logic here 
      if(bExpanded){ 

      } 
      //custom logic 

      this._getIcon().$().attr("aria-expanded", this.getExpanded()); 
      this._toggleExpandCollapse(); 
      this._toggleCssClasses(); 

      this.fireExpand({ expand : bExpanded }); 
      return this; 
     }; 
+0

喜瑞安,當切換摺疊完成該事件的工作很好,但我想添加一些動作在它崩潰之前,像崩潰之前的警告信息。 任何想法改善。 – Bunchureach

+0

@Bunchureach我看到了,我會嘗試覆蓋原型鏈Panel.prototype.setExpanded,通過查看源代碼https://github.com/SAP/openui5/blob/master/src/sap.m/src/sap /m/Panel.js。我相信你的自定義的東西可以在this.fireExpand() –

+0

之前添加我還不明白,但它好像你希望我改變默認的原型鏈代碼。如果是這樣,也許它會工作,但它可能會影響到其他函數調用相同的函數「setExpanded」,對於我來說,我只是想做到只有面板圖標。任何其他想法? – Bunchureach