|
1 | 1 | --- |
2 | 2 | layout: post |
3 | | -title: DataSource Binding and Custom Items in Blazor Menu Bar | Syncfusion |
| 3 | +title: Data Source Binding and Custom Items in Blazor Menu Bar | Syncfusion |
4 | 4 | description: Learn here all about data source binding and custom items in Syncfusion Blazor Menu Bar component and more. |
5 | 5 | platform: Blazor |
6 | 6 | control: Menu Bar |
7 | 7 | documentation: ug |
8 | 8 | --- |
9 | 9 |
|
10 | | -# DataSource Binding and Custom Items in Blazor Menu Bar Component |
11 | | - |
12 | | -The [Blazor Menu Bar](https://www.syncfusion.com/blazor-components/blazor-menu-bar) supports data source bindings such as data source that can be structured as `Self-referential` data. |
| 10 | +# Data Source Binding and Custom Items in Blazor Menu Bar Component |
13 | 11 |
|
| 12 | +The [Blazor Menu Bar](https://www.syncfusion.com/blazor-components/blazor-menu-bar) component supports data source binding, including structures such as self-referential data. This allows for dynamic generation of menu hierarchies from various data sources. |
14 | 13 | ## Self-referential data |
15 | 14 |
|
16 | | -Menu Bar can be populated from self-referential data structure that contains data with `ParentId` mapping. |
| 15 | +The Menu Bar can be populated from a self-referential data structure that defines parent-child relationships through a `ParentId` mapping. |
17 | 16 |
|
18 | 17 | In the following example, the **id**, **pId**, and **text** columns from self-referential data have been mapped to the [ItemId](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.MenuFieldSettings.html#Syncfusion_Blazor_Navigations_MenuFieldSettings_ItemId), [ParentId](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.MenuFieldSettings.html#Syncfusion_Blazor_Navigations_MenuFieldSettings_ParentId), and [Text](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.MenuFieldSettings.html#Syncfusion_Blazor_Navigations_MenuFieldSettings_Text) fields, respectively. |
19 | 18 |
|
@@ -70,13 +69,14 @@ In the following example, the **id**, **pId**, and **text** columns from self-re |
70 | 69 |
|
71 | 70 | ``` |
72 | 71 |
|
| 72 | +{% previewsample "https://blazorplayground.syncfusion.com/embed/BZrysjNKVhgmHQHC?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %} |
73 | 73 |  |
74 | 74 |
|
75 | 75 | N> In the above example, `TValue` is specified as `MenuItemModel` because the menu is rendered using the `Items` property. |
76 | 76 |
|
77 | 77 | ## Handling Self-Referential Data with CustomMenuItem TValue in MenuTemplate |
78 | 78 |
|
79 | | -When using TValue with CustomMenuItem in the [MenuTemplates](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.MenuTemplates-1.html), self-referential data structures with ParentId mapping are not supported. To address this limitation, you need to manually map the parent and child menu items within the menu template. In the following example, we demonstrate how to configure the SfMenu component using self-referential data with CustomMenuItem as the TValue in the MenuTemplate. |
| 79 | +When using a custom generic type (`TValue="CustomMenuItem"`) with [`MenuTemplates`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.MenuTemplates-1.html), the Menu Bar's built-in self-referential data processing based on `ParentId` mapping is not directly supported. To address this limitation, you need to manually map the parent and child menu items within the menu template. In the following example, we demonstrate how to configure the SfMenu component using self-referential data with CustomMenuItem as the TValue in the MenuTemplate. |
80 | 80 |
|
81 | 81 | ```cshtml |
82 | 82 | @using Syncfusion.Blazor.Navigations |
@@ -197,11 +197,14 @@ When using TValue with CustomMenuItem in the [MenuTemplates](https://help.syncfu |
197 | 197 | } |
198 | 198 | ``` |
199 | 199 |
|
| 200 | +{% previewsample "https://blazorplayground.syncfusion.com/embed/VXhIijtKhVJJaFLz?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %} |
200 | 201 |  |
201 | 202 |
|
202 | 203 | ## Custom Menu Bar Items |
203 | 204 |
|
204 | | -To customize Menu Bar items in your application, set your customized template using [MenuTemplates](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.MenuTemplates-1.html). In the following example, the Menu Bar has been rendered with customized Menu Bar items. |
| 205 | +To customize the rendering of Menu Bar items, define a custom template using the [`MenuTemplates`](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.MenuTemplates-1.html) component. This allows the embedding of rich content, custom styles, or interactive elements directly within each menu item. |
| 206 | + |
| 207 | +The following example demonstrates rendering a Menu Bar with extensively customized items, including images, badges, and a detailed "About Us" card. |
205 | 208 |
|
206 | 209 | ```cshtml |
207 | 210 |
|
@@ -377,4 +380,5 @@ To customize Menu Bar items in your application, set your customized template us |
377 | 380 |
|
378 | 381 | ``` |
379 | 382 |
|
| 383 | +{% previewsample "https://blazorplayground.syncfusion.com/embed/BtreijXUVhyRIyrJ?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %} |
380 | 384 |  |
0 commit comments