Search code examples
javascriptjqueryarraysdynatree

How do I create an object array to load dummy data into dynatree?


I am creating a wireframe that will use dynatree to display a tree. I would like to load some dummy data into the tree using an object array. I read the documentation and was able to load the parents using:

$(function() {
$("#catTree").dynatree({
   children: ["Category 1","Category 2","Category 3","Category 4","Category 5","Category 6","Category 7","Category 8","Category 9"],
...

How do I amend this to show children of these categories? For example:

Category 1 sub category1 sub category2

etc..


Solution

  • children: [
      {title: "Item 1"},
      {title: "Item 2",
        children: [
          {title: "Sub-item 2.1"},
          {title: "Sub-item 2.2"}
        ]
      },
      {title: "Item 3"}
    ]