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
A treeview has slots available for replacing specific types of nodes. The `text`, `checkbox`, `radio`, and `loading` slots replace the correpsonding types of nodes. For more info, see [the docs](./#slots).
838
+
A treeview has slots available for replacing specific types of nodes. The `text`, `checkbox`, `radio`, `loading-root` and `loading` slots replace the correpsonding types of nodes. For more info, see [the docs](./#slots).
839
839
840
840
```{=html5}
841
841
<details>
@@ -852,7 +852,10 @@ A treeview has slots available for replacing specific types of nodes. The `text`
Child nodes can be loaded asynchronously by providing a function to the `loadChildrenAsync` property in a node's `treeNodeSpec` (or use `modelDefaults` to use the same method for all nodes). The `loadChildrenAsync` can take the parent node's model data as an argument, and should return a Promise that resolves to an array of model data to add as children.
1060
+
Two types of asynchronous loading are available. The first loads the root data for the treeview itself, and the second asynchronously loads child data when a node is expanded.
1061
+
1062
+
You can load root nodes asynchronously by providing a function to the `loadNodesAsync` property of the treeview. The function should return a Promise that resolves to an array of model data to add as root nodes.
1063
+
1064
+
You can load child nodes asynchronously by providing a function to the `loadChildrenAsync` property in a node's `treeNodeSpec` (or use `modelDefaults` to use the same method for all nodes). The function can take the parent node's model data as an argument, and should return a Promise that resolves to an array of model data to add as children.
| initialModel | Array | The data model containing [model data](#model-data) | -| Yes |
100
+
| initialModel | Array | The data model containing [model data](#model-data) | `[]`| |
101
101
| customAriaKeyMap | Object | An object, the properties of which are arrays to keyCodes for various actions | See [Aria](#setting-key-bindings) | |
102
+
| loadNodesAsync | Function | A function that is called on mount to asynchronously load [model data](#model-data) | `null` | |
102
103
| modelDefaults | Object | An object containing defaults for all nodes that do not specify the given properties | `{}` | |
103
104
| selectionMode | String | How selection should operate (see [Selection Mode](#selection-mode)) | `null` (cannot select nodes) | |
104
-
| skinClass | String | A class name to apply to the tree that specifies a skin to use (see [Skins](#skins)) | `"grtv-default-skin"` | |
105
+
| skinClass | String | A class name to apply to the tree that specifies a skin to use (see [Skins](#skins)) | `"grtv-default-skin"` | |
105
106
106
107
## Selection Mode
107
108
@@ -116,7 +117,9 @@ When clicking on a node, it is only selected if the click target was not interac
116
117
117
118
## Model Data
118
119
119
-
The data passed to the treeview's `initialModel` prop should be an array of nodes, where each node should have:
120
+
Model data can be loaded either synchronously through the `initialModel` property or asynchronously through the `loadNodesAsync` property. If both are specified then the data from `initialModel` is overwritten when the `loadNodesAsync` function returns data.
121
+
122
+
The data passed to the treeview's `initialModel` prop or returned from `loadNodesAsync` should be an array of nodes, where each node should have:
120
123
121
124
* Required: A property with a value that will be used as the node's ID (by default the node looks for a property named `id`)
122
125
* Required: A property with a value that will be used as the node's label (by default the node looks for a property named `label`)
@@ -266,14 +269,17 @@ If specified, the `modelDefaults` property of the treeview will be merged with n
266
269
| treeViewNodeExpandedChange | Emitted when a node is expanded or collapsed | `target` The model of the target node <br/> `event` The original event |
267
270
| treeViewNodeSelectedChange | Emitted when a node is selected or deselected | `target` The model of the target node <br/> `event` The original event |
268
271
| treeViewNodeChildrenLoad | Emitted when a node's children are done loading asynchronously | `target` The model of the target node <br/> `event` The original event |
272
+
| treeViewRootNodesLoad | Emitted when the root nodes are done loading asynchronously | |
269
273
270
274
## CSS Classes
271
275
272
276
The display of the treeview can be customized via CSS using the following classes. Class names are organized in a hierarchy, so a containing node's class is the prefix of its child classes.
| `grtv-wrapper` | The wrapper div around the list of root nodes and the loading placeholder |
282
+
| `grtv-loading` | The placeholder shown when root nodes are loading asynchronously |
277
283
| `grtvn` | A single node's list item |
278
284
| `grtvn-self-selected` | A selected node |
279
285
| `grtvn-self` | The div containing the current node's UI |
@@ -330,7 +336,7 @@ A customizations object may have the following properties:
330
336
| classes.treeViewNodeSelfDeleteIcon | String | Classes to add to the `<i>` element containing the delete icon |
331
337
| classes.treeViewNodeChildrenWrapper | String | Classes to add to the wrapper div around the list of child nodes and the loading placeholder |
332
338
| classes.treeViewNodeChildren | String | Classes to add to the list of child nodes |
333
-
| classes.treeViewNodeLoading | String | Classes to add to the loading placeholder |
339
+
| classes.treeViewNodeLoading | String | Classes to add to the node children loading placeholder |
334
340
335
341
### Skins
336
342
@@ -340,27 +346,28 @@ If adding classes isn't enough, the entire default styles of the TreeView can be
340
346
341
347
Sometimes the entire content of a node (_e.g._, the checkbox or text) needs customization beyond what is available through classes. In this case, some slots are available in the TreeView to allow this customization.
0 commit comments