Create a ui5-tree-table dynamically with a dynamic number of columns depending on the model

473 Views Asked by At

Is there a way to create a treetable dynamically in a way to have a dynamic number of columns and rows? Lets say the attributes in the model are called 'ColX' where X stands for a counter. For every such attribute I want to create a column.

An example for a model that I found is working with a treetable looks like and would produce 3 columns and 2 first level rows:

    {
  "Nodes": [
    {
      "NodeID": 1,
      "HierarchyLevel": 0,
      "Description": "Level1Node1",
      "ParentNodeID": null,
      "DrillState": "expanded",
      "Col1": "col1-val1",
      "Col2": "col1-val2",
      "Col3": "col1-val3",
      "data": [
          {
              "NodeID": 11,
              "HierarchyLevel": 2,
              "Description": "11",
              "ParentNodeID": 1,
              "DrillState": "leaf",
              "Col1": "col11-val1",
              "Col2": "col11-val2",
              "Col3": "col11-val3"
            },
            {
                "NodeID": 12,
                "HierarchyLevel": 2,
                "Description": "12",
                "ParentNodeID": 1,
                "DrillState": "leaf",
                "Col1": "col12-val1",
                "Col2": "col12-val2",
                "Col3": "col12-val3"
            },
            {
                "NodeID": 16,
                "HierarchyLevel": 2,
                "Description": "1x",
                "ParentNodeID": 1,
                "DrillState": "leaf",
                "Col1": "col13-val1",
                "Col2": "col13-val2",
                "Col3": "col13-val3"
            }
        ]
    },
    {
        "NodeID": 2,
        "HierarchyLevel": 0,
        "Description": "Level1Node2",
        "ParentNodeID": null,
        "DrillState": "expanded",
        "Col1": "col2-val1",
        "Col2": "col2-val2",
        "Col3": "col2-val3",
        "data": [
            {
                "NodeID": 17,
                "HierarchyLevel": 2,
                "Description": "21",
                "ParentNodeID": 2,
                "DrillState": "leaf",
                "Col1": "col21-val1",
                "Col2": "col21-val2",
                "Col3": "col21-val3"
        }
      ]
    }
  ]
}
0

There are 0 best solutions below