-
Notifications
You must be signed in to change notification settings - Fork 80
Added new kb article grid-footer-template-top-grid #2502
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
Merged
xristianstefanov
merged 2 commits into
master
from
new-kb-grid-footer-template-top-grid-a0648161c0bf4d96a7029f92dd99b35c
Nov 8, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| --- | ||
| title: Footer Template at the Top of the Grid | ||
| description: Learn how to position the FooterTemplate of the Telerik Blazor Grid to appear at the top of the grid. | ||
| type: how-to | ||
| page_title: How to Relocate the FooterTemplate to the Top in Telerik Blazor Grid | ||
| slug: grid-footer-template-top-grid | ||
| tags: grid, blazor, footer, template, css, styling, top | ||
| res_type: kb | ||
| ticketid: 1668460 | ||
| --- | ||
|
|
||
| ## Environment | ||
|
|
||
| <table> | ||
| <tbody> | ||
| <tr> | ||
| <td>Product</td> | ||
| <td>Grid for Blazor</td> | ||
| </tr> | ||
| </tbody> | ||
| </table> | ||
|
|
||
| ## Description | ||
|
|
||
| This KB article answers the following questions: | ||
|
|
||
| - How to move the Footer Template to the top of the Grid? | ||
| - How can I display the aggregate results at the top of the Grid in Blazor? | ||
|
|
||
| ## Solution | ||
|
|
||
| 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. | ||
|
|
||
| ````RAZOR | ||
| <style> | ||
| .k-grid .k-grid-footer { | ||
| position: absolute; | ||
| border-bottom-width: 1px; | ||
| border-bottom-color: rgba(0, 0, 0, 0.08); | ||
| } | ||
|
|
||
| .k-grid .k-grid-header { | ||
| padding-top: 60px; | ||
| } | ||
| </style> | ||
|
|
||
| <TelerikGrid Data=@GridData Pageable="true" Height="300px"> | ||
| <GridAggregates> | ||
| <GridAggregate Field=@nameof(Employee.Salary) Aggregate="@GridAggregateType.Max" /> | ||
| <GridAggregate Field=@nameof(Employee.Salary) Aggregate="@GridAggregateType.Sum" /> | ||
| <GridAggregate Field=@nameof(Employee.EmployeeId) Aggregate="@GridAggregateType.Count" /> | ||
| </GridAggregates> | ||
| <GridColumns> | ||
| <GridColumn Field=@nameof(Employee.Salary) Title="Salary"> | ||
| <FooterTemplate> | ||
| Total salaries: @context.Sum?.ToString("C0") | ||
| <br /> | ||
| Highest salary: @context.Max?.ToString("C0") | ||
| </FooterTemplate> | ||
| </GridColumn> | ||
| <GridColumn Field=@nameof(Employee.Name)> | ||
| <FooterTemplate> | ||
| @{ | ||
| int? headCount = (int?)context?.AggregateResults | ||
| .FirstOrDefault(r => r.AggregateMethodName == "Count" && r.Member == nameof(Employee.EmployeeId))?.Value; | ||
| } | ||
| Total employees: @headCount | ||
| </FooterTemplate> | ||
| </GridColumn> | ||
| </GridColumns> | ||
| </TelerikGrid> | ||
|
|
||
| @code { | ||
| private List<Employee> GridData { get; set; } | ||
|
|
||
| protected override void OnInitialized() | ||
| { | ||
| GridData = new List<Employee>(); | ||
| var rand = new Random(); | ||
| for (int i = 0; i < 15; i++) | ||
| { | ||
| Random rnd = new Random(); | ||
| GridData.Add(new Employee() | ||
| { | ||
| EmployeeId = i, | ||
| Name = "Employee " + i.ToString(), | ||
| Salary = rnd.Next(1000, 5000), | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| public class Employee | ||
| { | ||
| public int EmployeeId { get; set; } | ||
| public string Name { get; set; } | ||
| public decimal Salary { get; set; } | ||
| } | ||
| } | ||
| ```` | ||
|
|
||
| ## See Also | ||
|
|
||
| - [Grid Overview](https://docs.telerik.com/blazor-ui/components/grid/overview) | ||
| - [Grid Footer Template](https://docs.telerik.com/blazor-ui/components/grid/templates/column-footer) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.