New to Telerik UI for ASP.NET MVC? Start a free 30-day trial
Show or Hide Grid Aggregates
Environment
| Product | Telerik UI for ASP.NET MVC Grid |
| Progress Telerik UI for ASP.NET MVC version | Created with the 2022.2.621 version |
Description
How to show and hide the aggregates in the Telerik UI for ASP.NET MVC Grid?
Solution
- Hook up for the event that, when triggered, will toggle the aggregates. The example below uses the
Changeevent of the Switch component. - Show or hide the aggregates based on a condition. To set up the aggregates, you can use the
aggregatemethod of the DataSource. To show or hide the aggregates, you can change the value of the template. The example below uses thefooterTemplateof the Grid in which the aggregate values are displayed.
Razor
@(Html.Kendo().Switch()
.Name("switch")
.Events(e => e.Change("onChange"))
.Messages(c => c.Checked("Show Aggregates").Unchecked("Hide Aggregates"))
.HtmlAttributes(new {style = "width:150px"})
)
@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.ProductViewModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.ProductName);
columns.Bound(p => p.UnitsInStock).Width(100);
columns.Bound(p => p.Discontinued).Width(100);
columns.Bound(p => p.UnitPrice).Width(100);
})
.Pageable()
.Scrollable()
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("EditingInline_Read", "Grid"))
)
)For the complete implementation of the suggested approach, refer to the following Telerik REPL example.