You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: concepts/05 UI Components/Diagram/10 Data Binding/30 Hierarchical Array.md
+233-4Lines changed: 233 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,8 @@ Specify the following **required properties**: [nodes.keyExpr](/api-reference/10
10
10
11
11
During the binding process, the UI component creates a shape for every bound node and all connectors that are between a node and its children. Note that the edges are not maintained as entities in a data source, thus the detached connector disappears after it is rebound.
12
12
13
+

14
+
13
15
---
14
16
##### jQuery
15
17
@@ -18,7 +20,7 @@ During the binding process, the UI component creates a shape for every bound nod
18
20
$("#diagram").dxDiagram({
19
21
nodes: {
20
22
dataSource: new DevExpress.data.ArrayStore({
21
-
key: "this",
23
+
key: "ID",
22
24
data: employees
23
25
}),
24
26
keyExpr: "ID",
@@ -29,7 +31,7 @@ During the binding process, the UI component creates a shape for every bound nod
29
31
});
30
32
31
33
<!-- tab: data.js -->
32
-
var employees = [{
34
+
const employees = [{
33
35
"ID": 3,
34
36
"Full_Name": "Arthur Miller",
35
37
"Title": "CTO",
@@ -62,6 +64,233 @@ During the binding process, the UI component creates a shape for every bound nod
62
64
}]
63
65
}];
64
66
65
-
---
67
+
##### Angular
66
68
67
-

69
+
<!-- tab: app.component.html -->
70
+
<dx-diagram>
71
+
<dxo-nodes
72
+
[dataSource]="dataSource"
73
+
keyExpr="ID"
74
+
textExpr="Title"
75
+
itemsExpr="Items"
76
+
>
77
+
</dxo-nodes>
78
+
</dx-diagram>
79
+
80
+
<!-- tab: app.component.ts -->
81
+
import { Component } from '@angular/core';
82
+
import ArrayStore from "devextreme/data/array_store";
83
+
import { Service } from "./app.service";
84
+
85
+
@Component({
86
+
selector: 'app-root',
87
+
templateUrl: './app.component.html',
88
+
styleUrls: ['./app.component.css'],
89
+
providers: [Service]
90
+
})
91
+
92
+
export class AppComponent {
93
+
dataSource: ArrayStore;
94
+
constructor(service: Service) {
95
+
this.dataSource = new ArrayStore({
96
+
key: "ID",
97
+
data: service.getEmployees(),
98
+
});
99
+
}
100
+
}
101
+
102
+
<!-- tab: app.service.ts -->
103
+
import { Injectable } from "@angular/core";
104
+
105
+
export class Employee {
106
+
ID: number;
107
+
Full_Name: string;
108
+
Title: string;
109
+
Items: Employee[];
110
+
}
111
+
112
+
const employees = [{
113
+
"ID": 3,
114
+
"Full_Name": "Arthur Miller",
115
+
"Title": "CTO",
116
+
"Items": [{
117
+
"ID": 6,
118
+
"Full_Name": "Brett Wade",
119
+
"Title": "IT Manager",
120
+
"Items": [{
121
+
"ID": 21,
122
+
"Full_Name": "Taylor Riley",
123
+
"Title": "Network Admin",
124
+
}, {
125
+
"ID": 23,
126
+
"Full_Name": "Wally Hobbs",
127
+
"Title": "Programmer",
128
+
}, {
129
+
"ID": 24,
130
+
"Full_Name": "Brad Jameson",
131
+
"Title": "Programmer",
132
+
}]
133
+
}, {
134
+
"ID": 9,
135
+
"Full_Name": "Barb Banks",
136
+
"Title": "Support Manager",
137
+
"Items": [{
138
+
"ID": 18,
139
+
"Full_Name": "James Anderson",
140
+
"Title": "Support Assistant",
141
+
}]
142
+
}]
143
+
}];
144
+
145
+
@Injectable()
146
+
export class Service {
147
+
getEmployees() {
148
+
return employees;
149
+
}
150
+
}
151
+
152
+
##### Vue
153
+
154
+
<!-- tab: App.vue -->
155
+
<template>
156
+
<DxDiagram>
157
+
<DxNodes
158
+
:data-source="dataSource"
159
+
:key-expr="'ID'"
160
+
:text-expr="'Title'"
161
+
:items-expr="'Items'"
162
+
/>
163
+
</DxDiagram>
164
+
</template>
165
+
166
+
<script>
167
+
import {
168
+
DxDiagram, DxNodes
169
+
} from 'devextreme-vue/diagram';
170
+
import ArrayStore from 'devextreme/data/array_store';
171
+
import service from './data.js';
172
+
173
+
export default {
174
+
components: {
175
+
DxDiagram, DxNodes
176
+
},
177
+
data() {
178
+
return {
179
+
dataSource: new ArrayStore({
180
+
key: 'ID',
181
+
data: service.getEmployees(),
182
+
})
183
+
};
184
+
}
185
+
};
186
+
</script>
187
+
188
+
<!-- tab: data.js -->
189
+
const employees = [{
190
+
"ID": 3,
191
+
"Full_Name": "Arthur Miller",
192
+
"Title": "CTO",
193
+
"Items": [{
194
+
"ID": 6,
195
+
"Full_Name": "Brett Wade",
196
+
"Title": "IT Manager",
197
+
"Items": [{
198
+
"ID": 21,
199
+
"Full_Name": "Taylor Riley",
200
+
"Title": "Network Admin",
201
+
}, {
202
+
"ID": 23,
203
+
"Full_Name": "Wally Hobbs",
204
+
"Title": "Programmer",
205
+
}, {
206
+
"ID": 24,
207
+
"Full_Name": "Brad Jameson",
208
+
"Title": "Programmer",
209
+
}]
210
+
}, {
211
+
"ID": 9,
212
+
"Full_Name": "Barb Banks",
213
+
"Title": "Support Manager",
214
+
"Items": [{
215
+
"ID": 18,
216
+
"Full_Name": "James Anderson",
217
+
"Title": "Support Assistant",
218
+
}]
219
+
}]
220
+
}];
221
+
222
+
export default {
223
+
getEmployees() {
224
+
return employees;
225
+
}
226
+
}
227
+
228
+
##### React
229
+
230
+
<!-- tab: App.js -->
231
+
import React from "react";
232
+
import Diagram, { Nodes } from "devextreme-react/diagram";
233
+
import ArrayStore from "devextreme/data/array_store";
0 commit comments