Skip to content

Commit 63ecdf3

Browse files
kendo-botKB Botxristianstefanov
authored
Added new kb article grid-footer-template-top-grid (#2502)
* Added new kb article grid-footer-template-top-grid * kb(grid): apply fixes as per comments --------- Co-authored-by: KB Bot <kb-bot@telerik.com> Co-authored-by: Hristian Stefanov <Hristian.Stefanov@progress.com>
1 parent eae9d4b commit 63ecdf3

File tree

1 file changed

+104
-0
lines changed

1 file changed

+104
-0
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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+
This KB article answers the following questions:
26+
27+
- How to move the Footer Template to the top of the Grid?
28+
- How can I display the aggregate results at the top of the Grid in Blazor?
29+
30+
## Solution
31+
32+
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.
33+
34+
````RAZOR
35+
<style>
36+
.k-grid .k-grid-footer {
37+
position: absolute;
38+
border-bottom-width: 1px;
39+
border-bottom-color: rgba(0, 0, 0, 0.08);
40+
}
41+
42+
.k-grid .k-grid-header {
43+
padding-top: 60px;
44+
}
45+
</style>
46+
47+
<TelerikGrid Data=@GridData Pageable="true" Height="300px">
48+
<GridAggregates>
49+
<GridAggregate Field=@nameof(Employee.Salary) Aggregate="@GridAggregateType.Max" />
50+
<GridAggregate Field=@nameof(Employee.Salary) Aggregate="@GridAggregateType.Sum" />
51+
<GridAggregate Field=@nameof(Employee.EmployeeId) Aggregate="@GridAggregateType.Count" />
52+
</GridAggregates>
53+
<GridColumns>
54+
<GridColumn Field=@nameof(Employee.Salary) Title="Salary">
55+
<FooterTemplate>
56+
Total salaries: @context.Sum?.ToString("C0")
57+
<br />
58+
Highest salary: @context.Max?.ToString("C0")
59+
</FooterTemplate>
60+
</GridColumn>
61+
<GridColumn Field=@nameof(Employee.Name)>
62+
<FooterTemplate>
63+
@{
64+
int? headCount = (int?)context?.AggregateResults
65+
.FirstOrDefault(r => r.AggregateMethodName == "Count" && r.Member == nameof(Employee.EmployeeId))?.Value;
66+
}
67+
Total employees: @headCount
68+
</FooterTemplate>
69+
</GridColumn>
70+
</GridColumns>
71+
</TelerikGrid>
72+
73+
@code {
74+
private List<Employee> GridData { get; set; }
75+
76+
protected override void OnInitialized()
77+
{
78+
GridData = new List<Employee>();
79+
var rand = new Random();
80+
for (int i = 0; i < 15; i++)
81+
{
82+
Random rnd = new Random();
83+
GridData.Add(new Employee()
84+
{
85+
EmployeeId = i,
86+
Name = "Employee " + i.ToString(),
87+
Salary = rnd.Next(1000, 5000),
88+
});
89+
}
90+
}
91+
92+
public class Employee
93+
{
94+
public int EmployeeId { get; set; }
95+
public string Name { get; set; }
96+
public decimal Salary { get; set; }
97+
}
98+
}
99+
````
100+
101+
## See Also
102+
103+
- [Grid Overview](https://docs.telerik.com/blazor-ui/components/grid/overview)
104+
- [Grid Footer Template](https://docs.telerik.com/blazor-ui/components/grid/templates/column-footer)

0 commit comments

Comments
 (0)