0

Is it possible to have two arrays in each object, like so:

[
  {
    "id": 1,
    "title": "Drink",
    "subcategories": [
      {
        "id": 11,
        "title": "Alcoholic",
        "subcategories": [
          {
            "id": 111,
            "title": "Margarita",
            "subcategories": [],
            "products": []
          },
        ],
        "products": [
          {
        "id": 12,
        "title": "Budweiser"
          }
        ]
      }
    ],
    "products": [
      {
        "id": 2,
        "title": "Coca Cola"
      }
    ]
  }
]

Here you have two arrays, subcategories and products, in each object. Instead of just the nodes array found in the examples:

{
    'id': 1,
    'title': 'node1',
    'nodes': [
      {
        'id': 11,
        'title': 'node1.1',
        'nodes': [
          {
            'id': 111,
            'title': 'node1.1.1',
            'nodes': []
          }
        ]
      },
      {
        'id': 12,
        'title': 'node1.2',
        'nodes': []
      }
    ]
  }......

When using the UI Tree drag and drop, if I drag products contents into a parent category then how will it know to fill the products array and not the subcategories array. I'm not sure how to specify this during the drag and drop. Adding a new item is easy because I can just push to the selected array, but I do not see how the drag and drop would know which to push to. Sorry if I have been unclear. Let me know if I need to explain more. Thanks.

3
  • You need to map your data to the expected structure ...either at server or by using javascript methods Commented Jan 12, 2016 at 6:20
  • the innermost subcategories and products could certainly hold data, but they are not nodes. You wouldn't be able to move nodes from other areas into those arrays. Commented Jan 12, 2016 at 6:23
  • Okay, I was hoping this could be designed so only subcategories could have children...which could be products or more subcategories, but products are not allowed children Commented Jan 12, 2016 at 6:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.