Skip to content

Commit 118efe6

Browse files
authored
docs(grid): Update No Data Template example and remove misleading text
1 parent bdcd99a commit 118efe6

File tree

1 file changed

+24
-33
lines changed

1 file changed

+24
-33
lines changed
Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: No Data Template
33
page_title: Grid - No Data Template
4-
description: Use custom no data templates in Grid for Blazor.
4+
description: Use custom no data templates in the Telerik Grid for Blazor when the component has no items to display.
55
slug: grid-templates-no-data
6-
tags: telerik,blazor,grid,templates,no,data
6+
tags: telerik, blazor, grid, templates
77
published: True
88
position: 38
99
---
@@ -13,60 +13,51 @@ position: 38
1313

1414
The `NoDataTemplate` allows you to define custom content when the Grid has no data to show. It lets you change the default **No records available** localizable text.
1515

16-
>caption Custom content for an empty Grid
17-
18-
![Blazor Grid No Data Template](images/grid-no-data-template.gif)
19-
20-
>caption Use the NoDataTemplate to override the message shown while the data is still loading or when you try to filter a non-existing item
16+
>caption Using NoDataTemplate
2117
2218
````CSHTML
23-
@* The example showcases a Grid with a delay upon initializing its data and filtering on non-existing data *@
24-
25-
<TelerikGrid Data="@MyData" Height="400px" Width="830px"
26-
Pageable="true"
27-
FilterMode="Telerik.Blazor.GridFilterMode.FilterRow">
19+
<TelerikGrid Data="@GridData"
20+
FilterMode="@GridFilterMode.FilterRow"
21+
Height="400px"
22+
Pageable="true">
2823
<GridToolBarTemplate>
29-
<GridCommandButton OnClick="@LoadData">Add Data</GridCommandButton>
24+
<GridCommandButton OnClick="@LoadData">Load Data</GridCommandButton>
3025
</GridToolBarTemplate>
3126
<GridColumns>
32-
<GridColumn Field="@(nameof(SampleData.Id))" Width="400px" />
33-
<GridColumn Field="@(nameof(SampleData.Name))" Title="Employee Name" Width="200px" />
34-
<GridColumn Field="@(nameof(SampleData.Team))" Title="Team" Width="200px" />
35-
<GridColumn Field="@(nameof(SampleData.HireDate))" Title="Hire Date" Width="200px" />
27+
<GridColumn Field="@(nameof(SampleData.Name))" Title="Employee Name" />
28+
<GridColumn Field="@(nameof(SampleData.Team))" />
29+
<GridColumn Field="@(nameof(SampleData.HireDate))" Title="Hire Date" DisplayFormat="{0:d}" />
3630
</GridColumns>
3731
<NoDataTemplate>
38-
<strong>No Data available / The data is still loading...</strong>
32+
<p><strong style="color: var(--kendo-color-primary);">No Data Available.</strong></p>
3933
</NoDataTemplate>
4034
</TelerikGrid>
4135
42-
@code {
43-
public IEnumerable<SampleData> MyData { get; set; }
36+
@code {
37+
private IEnumerable<SampleData>? GridData { get; set; }
4438
45-
async Task LoadData()
39+
private void LoadData()
4640
{
47-
await Task.Delay(2000);
48-
49-
MyData = Enumerable.Range(1, 30).Select(x => new SampleData
41+
GridData = Enumerable.Range(1, 30).Select(x => new SampleData
5042
{
5143
Id = x,
52-
Name = "name " + x,
53-
Team = "team " + x % 5,
54-
HireDate = DateTime.Now.AddDays(-x).Date
44+
Name = $"Name {x}",
45+
Team = $"Team {x % 3 + 1}",
46+
HireDate = DateTime.Today.AddMonths(-x)
5547
});
5648
}
5749
5850
public class SampleData
5951
{
6052
public int Id { get; set; }
61-
public string Name { get; set; }
62-
public string Team { get; set; }
63-
public DateTime HireDate { get; set; }
53+
public string Name { get; set; } = string.Empty;
54+
public string Team { get; set; } = string.Empty;
55+
public DateTime HireDate { get; set; } = DateTime.Today;
6456
}
6557
}
6658
````
6759

6860
## See Also
6961

70-
* [Live Demo: Grid Templates](https://demos.telerik.com/blazor-ui/grid/templates)
71-
* [Live Demo: Grid - No Data Template](https://demos.telerik.com/blazor-ui/grid/no-data-template)
72-
62+
* [Live Demo: Grid Templates](https://demos.telerik.com/blazor-ui/grid/templates)
63+
* [Live Demo: Grid - No Data Template](https://demos.telerik.com/blazor-ui/grid/no-data-template)

0 commit comments

Comments
 (0)