Skip to content

Commit 69df931

Browse files
author
KB Bot
committed
Added new kb article grid-footer-template-top-grid
1 parent efb1b6a commit 69df931

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
title: Footer Template at the Top of the Grid
3+
description: Learn how to position the FooterTemplate of the Telerik Blazor Grid to appear at the top of the grid.
4+
type: how-to
5+
page_title: How to Relocate the FooterTemplate to the Top in Telerik Blazor Grid
6+
slug: grid-footer-template-top-grid
7+
tags: grid, blazor, footer, template, css, styling, top
8+
res_type: kb
9+
ticketid: 1668460
10+
---
11+
12+
## Environment
13+
14+
<table>
15+
<tbody>
16+
<tr>
17+
<td>Product</td>
18+
<td>Grid for Blazor</td>
19+
</tr>
20+
</tbody>
21+
</table>
22+
23+
## Description
24+
25+
How to move the Footer Template to the top of the Grid?
26+
How can I display the aggregate results at the top of the Grid in Blazor?
27+
28+
## Solution
29+
30+
To reposition the `FooterTemplate` to appear at the top of the Grid, apply custom CSS for positioning. This involves using CSS to position the footer at the top of the grid and adding padding to the grid header to accommodate the footer's new position.
31+
32+
````RAZOR
33+
<style>
34+
.k-grid .k-grid-footer {
35+
position: absolute;
36+
border-bottom-width: 1px;
37+
border-bottom-color: rgba(0, 0, 0, 0.08);
38+
}
39+
40+
.k-grid .k-grid-header {
41+
padding-top: 60px;
42+
}
43+
</style>
44+
45+
<TelerikGrid Data=@GridData Pageable="true" Height="300px">
46+
<GridAggregates>
47+
<GridAggregate Field=@nameof(Employee.Salary) Aggregate="@GridAggregateType.Max" />
48+
<GridAggregate Field=@nameof(Employee.Salary) Aggregate="@GridAggregateType.Sum" />
49+
<GridAggregate Field=@nameof(Employee.EmployeeId) Aggregate="@GridAggregateType.Count" />
50+
</GridAggregates>
51+
<GridColumns>
52+
<GridColumn Field=@nameof(Employee.Salary) Title="Salary">
53+
<FooterTemplate>
54+
Total salaries: @context.Sum?.ToString("C0")
55+
<br />
56+
Highest salary: @context.Max?.ToString("C0")
57+
</FooterTemplate>
58+
</GridColumn>
59+
<GridColumn Field=@nameof(Employee.Name)>
60+
<FooterTemplate>
61+
@{
62+
int? headCount = (int?)context?.AggregateResults
63+
.FirstOrDefault(r => r.AggregateMethodName == "Count" && r.Member == nameof(Employee.EmployeeId))?.Value;
64+
}
65+
Total employees: @headCount
66+
</FooterTemplate>
67+
</GridColumn>
68+
</GridColumns>
69+
</TelerikGrid>
70+
71+
@code {
72+
private List<Employee> GridData { get; set; }
73+
74+
protected override void OnInitialized()
75+
{
76+
GridData = new List<Employee>();
77+
var rand = new Random();
78+
for (int i = 0; i < 15; i++)
79+
{
80+
Random rnd = new Random();
81+
GridData.Add(new Employee()
82+
{
83+
EmployeeId = i,
84+
Name = "Employee " + i.ToString(),
85+
Salary = rnd.Next(1000, 5000),
86+
});
87+
}
88+
}
89+
90+
public class Employee
91+
{
92+
public int EmployeeId { get; set; }
93+
public string Name { get; set; }
94+
public decimal Salary { get; set; }
95+
}
96+
}
97+
````
98+
99+
## See Also
100+
101+
- [Grid Overview](https://docs.telerik.com/blazor-ui/components/grid/overview)
102+
- [Grid Footer Template](https://docs.telerik.com/blazor-ui/components/grid/templates/column-footer)

0 commit comments

Comments
 (0)