Hello Heiko,
Thank you for the provided code snippet.
Below are presented a couple of approaches that could be undertaken in the current scenario. The recommended approach is to make use of the ClientFooterTemplate() option of the grid's columns.
1. The most straightforward one is to use the count of items in the model of the page. Choose the column in which footer will be positioned:
columns.Bound(p => p.FieldName).ClientFooterTemplate(Model.ProjectResults.Count().ToString());
2. The following approach demonstrates how to aggregate the DataSource while keeping the local data-binding:
.BindTo(data)
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.Aggregates(ag => ag.Add(f => f.FieldName).Count())
.PageSize(10)
)
It is important to add the ServerOperation(false) functionality (added in the snippet above).
After that, reference the aggregate in the ClientFooterTemplate:
columns.Bound(p => p.FieldName).ClientFooterTemplate("#=data.Name.Count#");
3. The ClientFooterTemplate could use a JavaScript function to return the count based on the number of items in the data source of the grid. Here is an example:
columns.Bound(p => p.FieldName).ClientFooterTemplate("#= showTotal()#");
Below is the function of the data count:
function showTotal() {
var grid = $("#Grid").data("kendoGrid");
var dataSource = grid.dataSource;
var totalRecords = dataSource.total();
return totalRecords;
}
If you need any further assistance feel free to contact me back.
Regards,
Anton Mironov
Progress Telerik
Progress is here for your business, like always.
Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.