2014-10-28 111 views
0

我有一個圖標選項卡篩選器,用戶選擇它時,我想顯示一棵樹。UI5:將樹添加到IconTabFilter內容

的我是如何處理的圖標的用戶選擇的邏輯在這裏

Handle IconTab Selection

提供我的問題是,這將創建樹節點不工作的JS。執行此操作的邏輯如下所示: -

var oModel = new sap.ui.model.json.JSONModel({ 
         "idocs1" : [ { 
           "Docnum" : "00063463", 
           "Mestyp" : "MATMAS", 
           "Status" : "53", 
           "Sndprn" : "EXTSYS1", 
           "Direct" : "Inbound", 
           "Message" : "Material 00002342 Created", 
           "messages" : [ { 
            "message" : "Material 00002342 Created" 
           } ], 
           "segments" : [ { 
            "segment" : "E1MARAM", 
            "fields" : [ { 
             "fieldName" : "MATNR" 
            } ] 

           } ] 
          } ] 
         }); 

         sap.ui.getCore().setModel(oModel); 

         var tgtPath = "/idocs1/0/segments"; 
         var oTree = new sap.ui.commons.Tree("tree"); 

         oTree.bindAggregation("nodes", tgtPath, function(
           sId, oContext) { 

          var treePath = oContext.getPath(); 

          var bindTextName = ''; 
          if (treePath.indexOf("fields") !== -1) { 
           bindTextName = "fieldName"; 
          } else { 
           bindTextName = "segment"; 
          } 

          alert("here = " + oContext + " ---- " 
            + bindTextName); 
          return new sap.ui.commons.TreeNode() 
            .bindProperty("text", bindTextName); 

         }); 


         var myButton = new sap.ui.commons.Button("btn"); 

         myButton.setText("Hello World!"); 

         myButton 
           .placeAt("idViewRoot--idViewDetail--toolBar-content"); 

         oTree 
           .placeAt("idViewRoot--idViewDetail--toolBar-content"); 

此邏輯存在於用戶選擇特定IconTab時調用的方法中。

我有一個按鈕來確保它將一些東西添加到IconTab內容(當樹邏輯被註釋掉時)。

我注意到,如果我試圖創建兩個相同ID的按鈕,那麼上面的代碼(即方法)會被調用兩次。

如果我啓用樹邏輯,該方法被調用兩次,因此我得到一個重複樹節點的錯誤。

任何幫助,非常感謝。

感謝

馬丁

+0

現在修好了。問題是,如果您在工廠函數「bindAggregation」中放置警報,則顯示錯誤並顯示一個複製樹ID。 – 2014-10-31 08:59:47

回答

0

是否有一個原因,爲什麼你想在以後添加的內容?您還可以爲每個IconTab添加一個特定的內容,當用戶點擊它時會顯示該內容。 這也應該可以解決你的問題。

如果這對您的情況不方便,我認爲您應該在IconTabBar或IconTabFilter上設置內容,方法是單擊IconTab並將其放在內容中。