Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(PanelBar): update content template example #2131

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 25 additions & 17 deletions components/panelbar/templates/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,21 @@ Without a Level, the ContentTemplate will be applied to all items that have no c
var item = context as PanelBarItem;

<div style="padding: 8px 16px;">
<span style="text-decoration: underline; color: blue;">
content template for: @item.Text
</span>
<br />
@if (item.Text == "Item 2")
@if (item.Text == "New Web Site")
{
<strong style="text-decoration: underline; color: green;">
content template for: @item.Text
</strong>
<br />
<TelerikButton ThemeColor="primary">Nested Component</TelerikButton>
}

else
{
<span style="text-decoration: solid; color: blue;">
content template for: @item.Text
</span>
<br />
}
</div>
}
</ContentTemplate>
Expand All @@ -51,12 +57,13 @@ Without a Level, the ContentTemplate will be applied to all items that have no c
</div>

@code {
public List<PanelBarItem> Items { get; set; }
private List<PanelBarItem> Items { get; set; }

public class PanelBarItem
{
public string Text { get; set; }
public List<PanelBarItem> Items { get; set; }
public ISvgIcon Icon { get; set; }
}

protected override void OnInitialized()
Expand All @@ -65,29 +72,34 @@ Without a Level, the ContentTemplate will be applied to all items that have no c
{
new PanelBarItem()
{
Text = "Item 1",
Text = "My Documents",
Icon = SvgIcon.FolderMore,
Items = new List<PanelBarItem>()
{
new PanelBarItem()
{
Text = "Item 1.1"
Text = "Reports",
Icon = SvgIcon.Folder,
},
new PanelBarItem()
new PanelBarItem
{
Text = "Item 1.2",
Text = "Projects",
Icon = SvgIcon.Folder,
Items = new List<PanelBarItem>()
{
new PanelBarItem()
{
Text = "Item 1.2.1"
Text = "November",
Icon = SvgIcon.Folder
}
}
}
}
},
new PanelBarItem()
{
Text = "Item 2"
Text = "New Web Site",
Icon = SvgIcon.FolderMore
}
};

Expand All @@ -96,10 +108,6 @@ Without a Level, the ContentTemplate will be applied to all items that have no c
}
````

>caption The result from the code snippet above

![ContentTemplate example](images/content-template-example.png)

## See Also

* [Data Binding a PanelBar]({%slug panelbar-data-binding-overview%})
Expand Down
Binary file not shown.
Loading