0
我有一個圖標選項卡篩選器,用戶選擇它時,我想顯示一棵樹。UI5:將樹添加到IconTabFilter內容
的我是如何處理的圖標的用戶選擇的邏輯在這裏
提供我的問題是,這將創建樹節點不工作的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的按鈕,那麼上面的代碼(即方法)會被調用兩次。
如果我啓用樹邏輯,該方法被調用兩次,因此我得到一個重複樹節點的錯誤。
任何幫助,非常感謝。
感謝
馬丁
現在修好了。問題是,如果您在工廠函數「bindAggregation」中放置警報,則顯示錯誤並顯示一個複製樹ID。 – 2014-10-31 08:59:47