在SAPUI5 TreeTable

时间:2015-10-09 09:31:23

标签: sapui5

在treeTable中,我不想在第一个列(在树中)中显示第三个节点之后的数据,即 connList 数据。我不能从JSON中删除节点,因为我必须将它用于另一列。是否可以从json中删除connList节点。如果有的话请建议我解决方案。感谢Avance!

createContent:function(oController){

使用 connList 节点的示例JSON -

    var response={"name": "Root", "checked": "Checked",
            "dataList": [
                {"name": "Parent1",
                    "exList": [
                        {"name": "SubParent1",
                            "sysList": [{"name": "Child1", "externalId": "External 1",
                                "connList": [ {"id":1, "name": "conn1" },
                                    {"id":2, "name": "conn2" },
                                    {"id":3, "name": "conn3"}
                                ]
                            },
                                {"name": "Child2", "externalId": "External 2" }
                            ]
                        }
                    ]
                },
                {"name": "Parent2",
                    "exList": [
                        {"name": "SubParent2",
                            "sysList": [{ "name": "Child3", "externalId": "External 3" },
                                { "name": "Child4", "externalId": "External 4" }
                            ]
                        }
                    ]
                }
            ]
        };

TreeTable会在这里 -

    var inputListBox = new sap.ui.commons.ListBox();
    inputListBox.bindAggregation("items","connList",function(oId,oContext){
        return new sap.ui.core.ListItem({
            key: oContext.getProperty("id"),
            text: oContext.getProperty("name")
        });
    });
    var oTable = new sap.ui.table.TreeTable("treeTable",{
        columns: [
            new sap.ui.table.Column({label: "Tree column", template:new sap.ui.commons.TriStateCheckBox({
                  text: '{name}',
                  selectionState: '{checked}'
              })}),
            new sap.ui.table.Column({label: "Child Column", template: "externalId"}),
            new sap.ui.table.Column({
                label: new sap.ui.commons.Label({text: "Connection", design:sap.ui.commons.LabelDesign.Bold}),
                template: new sap.ui.commons.DropdownBox({
                    "association:listBox" : inputListBox
                })
            })
        ],
          selectionMode : sap.ui.table.SelectionMode.Multi,
          enableColumnReordering : true,
          expandFirstLevel : true
    });

    var mappingModel = new sap.ui.model.json.JSONModel({listData:response});
    sap.ui.getCore().setModel(mappingModel, "mappingModel");
    oTable.setModel(mappingModel);
    oTable.bindRows("/listData/dataList");
    mappingModel.refresh(true);
    return oTable;
}

1 个答案:

答案 0 :(得分:0)

您可以将要扩展为新树级别的属性定义为绑定参数:

 oTable.bindRows({path: "/listData/dataList", parameters: {arrayNames: ["dataList","exList","sysList" ]} });

除了one example之外,在文档中找不到这个内容。您可以找到示例in the openui5 github的来源。