Skip to content

Commit 24157fc

Browse files
authored
docs(grid): Update No Data Template example and remove misleading text (#2487)
* docs(grid): Update No Data Template example and remove misleading text * delete image and link to article
1 parent a923c69 commit 24157fc

File tree

2 files changed

+25
-32
lines changed

2 files changed

+25
-32
lines changed
Binary file not shown.
Lines changed: 25 additions & 32 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,53 @@ 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
16+
The Grid will also show its default or custom `NoDataTemplate` while loading its initial data. To help users distinguish between the "no data" and "still loading" states, [display a LoaderContainer over the Grid on initial load]({%slug grid-loading%}#example).
1717

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
18+
>caption Using NoDataTemplate
2119
2220
````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">
21+
<TelerikGrid Data="@GridData"
22+
FilterMode="@GridFilterMode.FilterRow"
23+
Height="400px"
24+
Pageable="true">
2825
<GridToolBarTemplate>
29-
<GridCommandButton OnClick="@LoadData">Add Data</GridCommandButton>
26+
<GridCommandButton OnClick="@LoadData">Load Data</GridCommandButton>
3027
</GridToolBarTemplate>
3128
<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" />
29+
<GridColumn Field="@(nameof(SampleData.Name))" Title="Employee Name" />
30+
<GridColumn Field="@(nameof(SampleData.Team))" />
31+
<GridColumn Field="@(nameof(SampleData.HireDate))" Title="Hire Date" DisplayFormat="{0:d}" />
3632
</GridColumns>
3733
<NoDataTemplate>
38-
<strong>No Data available / The data is still loading...</strong>
34+
<p><strong style="color: var(--kendo-color-primary);">No Data Available.</strong></p>
3935
</NoDataTemplate>
4036
</TelerikGrid>
4137
42-
@code {
43-
public IEnumerable<SampleData> MyData { get; set; }
38+
@code {
39+
private IEnumerable<SampleData>? GridData { get; set; }
4440
45-
async Task LoadData()
41+
private void LoadData()
4642
{
47-
await Task.Delay(2000);
48-
49-
MyData = Enumerable.Range(1, 30).Select(x => new SampleData
43+
GridData = Enumerable.Range(1, 30).Select(x => new SampleData
5044
{
5145
Id = x,
52-
Name = "name " + x,
53-
Team = "team " + x % 5,
54-
HireDate = DateTime.Now.AddDays(-x).Date
46+
Name = $"Name {x}",
47+
Team = $"Team {x % 3 + 1}",
48+
HireDate = DateTime.Today.AddMonths(-x)
5549
});
5650
}
5751
5852
public class SampleData
5953
{
6054
public int Id { get; set; }
61-
public string Name { get; set; }
62-
public string Team { get; set; }
63-
public DateTime HireDate { get; set; }
55+
public string Name { get; set; } = string.Empty;
56+
public string Team { get; set; } = string.Empty;
57+
public DateTime HireDate { get; set; } = DateTime.Today;
6458
}
6559
}
6660
````
6761

6862
## See Also
6963

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-
64+
* [Live Demo: Grid Templates](https://demos.telerik.com/blazor-ui/grid/templates)
65+
* [Live Demo: Grid - No Data Template](https://demos.telerik.com/blazor-ui/grid/no-data-template)

0 commit comments

Comments
 (0)