Skip to content

Commit d9ce2ec

Browse files
committed
[update] a dataset example for tree data loading
1 parent f982465 commit d9ce2ec

File tree

1 file changed

+53
-47
lines changed

1 file changed

+53
-47
lines changed

docs/tree/loading_data.md

Lines changed: 53 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -27,61 +27,67 @@ Here is an example of an appropriate data set:
2727
const dataset = [
2828
{
2929
"value": "Books",
30-
"id": "books",
30+
"id": "Books",
3131
"opened": true,
32-
"items": [
32+
"items": [
3333
{
34-
"value": "History",
35-
"id": "history",
36-
"items": [{
37-
"value": "John Mack Faragher",
38-
"id": "jmf",
39-
"icon": {
40-
"folder": "fas fa-book",
41-
"openFolder": "fas fa-book-open",
42-
"file": "fas fa-file"
34+
"value": "Thrillers",
35+
"id": "Thrillers",
36+
"opened": true,
37+
"items": [
38+
{
39+
"value": "Bestsellers",
40+
"id": "Bestsellers",
41+
"items": [
42+
{
43+
"value": "Lawrence Block",
44+
"id": "Lawrence Block",
45+
}
46+
]
47+
},
48+
{
49+
"value": "Robert Crais",
50+
"id": "Robert Crais",
51+
},
52+
{
53+
"value": "Ian Rankin",
54+
"id": "Ian Rankin",
55+
},
56+
{
57+
"value": "James Johns",
58+
"id": "James Johns",
59+
"checked": true,
60+
},
61+
{
62+
"value": "Nancy Atherton",
63+
"id": "Nancy Atherton",
64+
"checked": true
4365
}
44-
},
45-
{
46-
"value": "Jim Dwyer",
47-
"id": "jd"
48-
},
49-
{
50-
"value": "Larry Schweikart",
51-
"id": "ls"
52-
}]
53-
},
66+
]
67+
},
5468
{
5569
"value": "Fiction & Fantasy",
56-
"id": "fantasy",
57-
"items": [{
58-
"value": "Audrey Niffenegger",
59-
"id": "af"
60-
},
61-
{
62-
"value": "Philip Roth",
63-
"id": "pr"
64-
}]
70+
"id": "Fiction & Fantasy",
71+
"items": [
72+
{
73+
"value": "Audrey Niffenegger",
74+
"id": "Audrey Niffenegger"
75+
},
76+
{
77+
"value": "Philip Roth",
78+
"id": "Philip Roth"
79+
}
80+
]
6581
},
66-
{
67-
"value": "Teens",
68-
"id": "teens",
69-
"items": [{
70-
"value": "Joss Whedon",
71-
"id": "jw"
72-
},
73-
{
74-
"value": "Meg Cabot",
75-
"id": "mc"
76-
},
77-
{
78-
"value": "Garth Nix",
79-
"id": "gn"
80-
}]
81-
}
8282
]
83-
}
83+
},
8484
];
85+
86+
const tree = new dhx.Tree("tree", {
87+
checkbox: true,
88+
});
89+
90+
tree.data.parse(dataset);
8591
~~~
8692

8793
Each object in the data set contains configuration of a tree item. The structure of an item is rather flexible. It may include:

0 commit comments

Comments
 (0)