Skip to content

Commit e70f64c

Browse files
chore(drawer): add example for data binding to custom field names
1 parent dde43bb commit e70f64c

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

components/drawer/data-bind.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This article has the following sections:
1616

1717
* The available (bindable) [features of a drawer item](#drawer-item-features).
1818
* How to match fields in the model with the drawer item [data bindings](#data-bindings).
19-
19+
* [Example](#example---data-binding-to-non-default-field-names) of using non-default field names for data binding.
2020

2121
## Drawer Item Features
2222

@@ -55,6 +55,37 @@ public class DrawerItem
5555
}
5656
````
5757

58+
## Example - Data Binding to Non-Default Field Names
59+
60+
````CSHTML
61+
@* This example shows how you can data bind the drawer and set the field names it will use from the model
62+
Place it in the MainLayout.razor so you can use it for navigation:
63+
https://docs.telerik.com/blazor-ui/components/drawer/navigation
64+
*@
65+
66+
<TelerikDrawer Data="@Data" UrlField="ItemUrl" TextField="ItemText" IconField="ItemIcon"
67+
MiniMode="true" Mode="@DrawerMode.Push" Expanded="true">
68+
<Content>
69+
@Body
70+
</Content>
71+
</TelerikDrawer>
72+
73+
@code {
74+
IEnumerable<DrawerItem> Data { get; set; } =
75+
new List<DrawerItem>
76+
{
77+
new DrawerItem { ItemText = "Counter", ItemIcon = IconName.Plus, ItemUrl = "counter" },
78+
new DrawerItem { ItemText = "FetchData", ItemIcon = IconName.GridLayout, ItemUrl = "fetchdata" },
79+
};
80+
81+
public class DrawerItem
82+
{
83+
public string ItemText { get; set; }
84+
public string ItemIcon { get; set; }
85+
public string ItemUrl { get; set; }
86+
}
87+
}
88+
````
5889

5990

6091

0 commit comments

Comments
 (0)