amsik / liquor-tree

Tree component based on Vue.js
MIT License
398 stars 94 forks source link

How to access data coming from server without changing its structure? #231

Open egeersoz opened 3 years ago

egeersoz commented 3 years ago

I have the following data:

"Conditions": [
      {
        "Values": [
          "test"
        ],
        "Operator": "Equals",
        "Condition Type": "Project Name Rule"
      },
      {
        "Values": [
          "flower"
        ],
        "Operator": "Contains",
        "Condition Type": "Project Description Rule"
      },
      {
        "Conjunction": true,
        "Conditions": [
          {
            "Values": [
              "test value"
            ],
            "Operator": "Does Not Contain",
            "Condition Type": "Project Description Rule"
          },
          {
            "Values": [
              "another test value"
            ],
            "Operator": "Does Not Equal",
            "Condition Type": "Project Name Rule"
          }
        ],
        "Condition Type": "Composite Rule"
      }
    ],
    "Condition Type": "Composite Rule"

I need to load this "as-is" into the tree, and then access each prop using, e.g. node.data.Operator or node.data.Values. Is this possible?

I'm not able to use computed properties in this scenario.

xavsio4 commented 3 years ago

In the tree options you can replace the data containers :

treeOptions: {
        propertyNames: {
           text: 'name',
           score: colorder,
           children: 'kids', ...
   }
}