Skip to content

Commit c2a3dc4

Browse files
ntachevaikoevska
andauthored
chore(PanelBar): update field bindings docs (#2986)
* chore(PanelBar): update field bindings docs * Update components/panelbar/data-binding/overview.md Co-authored-by: Iva Stefanova Koevska-Atanasova <koevska@progress.com> * Update components/panelbar/data-binding/overview.md --------- Co-authored-by: Iva Stefanova Koevska-Atanasova <koevska@progress.com>
1 parent 51a982f commit c2a3dc4

File tree

2 files changed

+52
-42
lines changed

2 files changed

+52
-42
lines changed

components/panelbar/data-binding/overview.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Each `PanelBarBinding` tag exposes the following properties that refer to item p
6666

6767
* ItemsField => Items
6868

69-
* Level - this is used for defining [different bindings for different levels](#multiple-level-bindings). If no level is set, the bindings are taken as default for any level that does not have explicit settings. You should have one `TelerikPanelBarBinding` without a level.
69+
* Level&mdash;this is used for defining [custom field bindings](#custom-field-bindings) or [different bindings for different levels](#multiple-level-bindings). If no level is set, the bindings are taken as default for any level that does not have explicit settings. You must have one `TelerikPanelBarBinding` without a level to set the default bindings.
7070

7171
>tip There are default values for the field names. If your model names match the defaults, you don't have to define them in the bindings settings.
7272
@@ -182,6 +182,15 @@ The following **Example** shows how to define simple binding to match item field
182182
183183
![Blazor PanelBar Data Binding](../images/panelbar-data-binding-basic-example.png)
184184

185+
### Custom Field Bindings
186+
187+
If you are using custom field names, you must ensure their binding for each level. Otherwise, the PanelBar will not render items where the field bindings are missing.
188+
189+
For that purpose, you must do either of the following:
190+
191+
* Add one `TelerikPanelBarBinding` without a level to set the default bindings.
192+
* Add `TelerikPanelBarBinding` for each level where you explicitly set the field bindings to your custom fields.
193+
185194
### Multiple Level Bindings
186195

187196
You can define different binding settings for the different levels of nodes in the PanelBar. With this, the children of a node can consume a different field than their parent, and this may make your application more flexible. If you use [hierarchical data binding](slug:panelbar-data-binding-hierarchical), the children can even use a different field or model from their parent.

components/panelbar/templates/header.md

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ position: 5
1313

1414
You can control and customize the rendering of the header items in the PanelBar by using the `HeaderTemplate`. It provides a `context` object that you can cast to the type that the PanelBar is bound to.
1515

16-
The `HeaderTemplate` of a level is defined under the `PanelBarBinding` tag.
16+
The `HeaderTemplate` of a level is defined under the `PanelBarBinding` tag. Set the `Level` parameter of the `PanelBarBinding` to specify the level the `HeaderTemplate` must be applied to.
1717

18-
If no levels are defined the `HeaderTemplate` will apply to the entire data.
18+
If the `Level` parameter of the `PanelBarBinding` is not set, the `HeaderTemplate` will apply to the entire data.
1919

2020
>caption Use HeaderTemplate to customize the rendering of the headers in the PanelBar
2121
@@ -26,7 +26,7 @@ If no levels are defined the `HeaderTemplate` will apply to the entire data.
2626
<TelerikPanelBar Data="@Items"
2727
@bind-ExpandedItems="@ExpandedItems">
2828
<PanelBarBindings>
29-
<PanelBarBinding>
29+
<PanelBarBinding Level="0">
3030
<HeaderTemplate>
3131
@{
3232
var item = context as PanelBarItem;
@@ -42,8 +42,9 @@ If no levels are defined the `HeaderTemplate` will apply to the entire data.
4242
</div>
4343
4444
@code {
45-
public List<PanelBarItem> Items { get; set; }
46-
public IEnumerable<object> ExpandedItems { get; set; } = new List<object>();
45+
private List<PanelBarItem> Items { get; set; }
46+
47+
private IEnumerable<object> ExpandedItems { get; set; } = new List<object>();
4748
4849
public class PanelBarItem
4950
{
@@ -60,50 +61,50 @@ If no levels are defined the `HeaderTemplate` will apply to the entire data.
6061
List<PanelBarItem> items = new List<PanelBarItem>();
6162
6263
items.Add(new PanelBarItem()
63-
{
64-
Id = 1,
65-
Text = "Project",
66-
ParentId = null,
67-
HasChildren = false,
68-
Icon = SvgIcon.Folder,
69-
Url = "projectURL.url"
70-
});
64+
{
65+
Id = 1,
66+
Text = "Project",
67+
ParentId = null,
68+
HasChildren = false,
69+
Icon = SvgIcon.Folder,
70+
Url = "projectURL.url"
71+
});
7172
7273
items.Add(new PanelBarItem()
73-
{
74-
Id = 2,
75-
Text = "Implementation",
76-
ParentId = null,
77-
HasChildren = true,
78-
Icon = SvgIcon.Code
79-
});
74+
{
75+
Id = 2,
76+
Text = "Implementation",
77+
ParentId = null,
78+
HasChildren = true,
79+
Icon = SvgIcon.Code
80+
});
8081
8182
items.Add(new PanelBarItem()
82-
{
83-
Id = 3,
84-
Text = "C#",
85-
ParentId = 2,
86-
HasChildren = false,
87-
Icon = SvgIcon.Cs
88-
});
83+
{
84+
Id = 3,
85+
Text = "C#",
86+
ParentId = 2,
87+
HasChildren = false,
88+
Icon = SvgIcon.Cs
89+
});
8990
9091
items.Add(new PanelBarItem()
91-
{
92-
Id = 4,
93-
Text = "HTML 5",
94-
ParentId = 2,
95-
HasChildren = false,
96-
Icon = SvgIcon.Html5
97-
});
92+
{
93+
Id = 4,
94+
Text = "HTML 5",
95+
ParentId = 2,
96+
HasChildren = false,
97+
Icon = SvgIcon.Html5
98+
});
9899
99100
items.Add(new PanelBarItem()
100-
{
101-
Id = 5,
102-
Text = "CSS",
103-
ParentId = 2,
104-
HasChildren = false,
105-
Icon = SvgIcon.Css
106-
});
101+
{
102+
Id = 5,
103+
Text = "CSS",
104+
ParentId = 2,
105+
HasChildren = false,
106+
Icon = SvgIcon.Css
107+
});
107108
108109
return items;
109110
}

0 commit comments

Comments
 (0)