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: components/treeview/data-binding/flat-data.md
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,8 @@ Flat data means that the entire collection of treeview items is available at one
18
18
19
19
The parent-child relationships are created through internal data in the model - the `ParentId` field which points to the `Id` of the item that will contain the current item. The root level has `null` for `ParentId`.
20
20
21
+
You must also provide the correct value for the `HasChildren` field - for items that have children, you must set it to `true` so that the expand arrow is rendered.
Hierarchical data means that the collection child items is provided in a field of its parent's model. By default, this is the `Items` field.
17
+
Hierarchical data means that the collection child items is provided in a field of its parent's model. By default, this is the `Items` field. If there are items for a certain node, it will have an expand icon. The `HasChildren` field can override this, however, but it is not required for hierarchical data binding.
18
18
19
-
This lets you gather separate collections of data and/or use different models at each different level. Note that the data binding settings are per level, so a certain level will always use the same bindings, regardless of the model they represent and their parent.
19
+
This approach of providing nodes lets you gather separate collections of data and/or use different models at each different level. Note that the data binding settings are per level, so a certain level will always use the same bindings, regardless of the model they represent and their parent.
20
20
21
21
>caption Example of hierarchical data that uses different models for the parent and the child. Using different models is not required.
22
22
@@ -38,7 +38,6 @@ This lets you gather separate collections of data and/or use different models at
38
38
public string Category { get; set; }
39
39
public List<ProductItem> Products { get; set; }
40
40
public bool Expanded { get; set; }
41
-
public bool HasChildren { get; set; }
42
41
}
43
42
44
43
public class ProductItem
@@ -48,7 +47,6 @@ This lets you gather separate collections of data and/or use different models at
48
47
// they are not really used in this example and you would have a collection of child items too
49
48
// see the information about multiple data bindings earlier in this article on using them
50
49
public bool Expanded { get; set; }
51
-
public bool HasChildren { get; set; }
52
50
}
53
51
54
52
@@ -71,8 +69,7 @@ This lets you gather separate collections of data and/or use different models at
71
69
{
72
70
Category = "Category 1",
73
71
Expanded = true,
74
-
Products = firstCategoryProducts, // this is how child items are provided
75
-
HasChildren = firstCategoryProducts?.Count > 0, // set this depending on the presence of items in the child items collection
72
+
Products = firstCategoryProducts // this is how child items are provided
Copy file name to clipboardExpand all lines: components/treeview/data-binding/overview.md
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -27,13 +27,13 @@ There are three modes of providing data to a treeview, and they all use the item
27
27
28
28
The treeview items provide the following features that you control through the corresponding fields in their data binding:
29
29
30
-
*`Id` - a unique identifier for the item. Required.
31
-
*`ParentId` - identifies the parent to whom the item belongs. Needed only when binding to flat data. All items with the same `ParentId` will be rendered at the same level. For a root level item, this must be `null`.
30
+
*`Id` - a unique identifier for the item. Required for binding to flat data.
31
+
*`ParentId` - identifies the parent to whom the item belongs. Required only when binding to flat data. All items with the same `ParentId` will be rendered at the same level. For a root level item, this must be `null`.
32
+
*`Expanded` - whether the item is expanded when it renders, or the user has to expand it manually.
33
+
*`HasChildren` - whether the item has children. Determines whether an expand arrow is rendered next to the item. Required for binding to flat data and for load-on-demand. With hierarchical data, the treeview will render the icon based on the existence of child items, but `HasChildren` will take precedence.
34
+
*`Items` - the collection of child items that will be rendered under the current item. Required only when binding to hierarchical data.
32
35
*`Text` - the text that will be shown on the item.
33
36
*`Icon` / `IconClass` / `ImageUrl` - the [Telerik icon]({%slug general-information/font-icons%}), a class for a custom font icon, or the URL to a raster image that will be rendered in the item. They have the listed order of precedence in case more than one is present in the data (that is, an `Icon` will have the highest importance).
34
-
*`Expanded` - whether the item is expanded when it renders, or the user has to expand it manually.
35
-
*`HasChildren` - whether the item has children. Determines whether an expand arrow is rendered next to the item. Required.
36
-
*`Items` - the collection of child items that will be rendered under the current item. Needed only when binding to hierarchical data.
0 commit comments