This is a migrated thread and some comments may be shown as answers.

Customserverbinding Groupable Statistics Problem

2 Answers 36 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ray
Top achievements
Rank 1
Ray asked on 12 Oct 2019, 09:52 AM

Grid Custom Server Binding Data

Group statistics have no data ,ClientGroupHeaderTemplate()  do not work;

GroupHeaderTemplate(g=>g.Count),g.Count is Null

Custom Server Binding  the way How to implement group statistics?

 

Examples Code:

@model System.Collections.IEnumerable
@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.Order>()
    .Name("Grid")
    .EnableCustomBinding(true)
    .BindTo(Model)
    .Columns(columns => {
        columns.Bound(o => o.OrderID).Groupable(false);
        columns.Bound(o => o.ShipCity).GroupHeaderTemplate(g=>g.Count);
        columns.Bound(o => o.ShipCountry).ClientGroupHeaderTemplate("ShipCountry: #= value # (Count: #= count#)");
        columns.Bound(o => o.ShipName);
    })
    .Pageable()
    .Sortable()
    .Filterable()
    .Scrollable()
    .Groupable()
    .DataSource(dataSource =>dataSource
        .Server()
        .Total((int)ViewData["total"])
        .Aggregates(aggregates =>
            {
                aggregates.Add(p => p.ShipCountry).Count();
            }
        )
     )
)

2 Answers, 1 is accepted

Sort by
0
Ray
Top achievements
Rank 1
answered on 12 Oct 2019, 09:55 AM
@model System.Collections.IEnumerable
 
@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.Order>()
    .Name("Grid")
    .EnableCustomBinding(true)
    .BindTo(Model)
    .Columns(columns => {
        columns.Bound(o => o.OrderID).Groupable(false);
        columns.Bound(o => o.ShipCity).GroupHeaderTemplate(g=>g.Count);
        columns.Bound(o => o.ShipCountry).ClientGroupHeaderTemplate("ShipCountry: #= value # (Count: #= count#)");
        columns.Bound(o => o.ShipName);
    })
    .Pageable()
    .Sortable()
    .Filterable()
    .Scrollable()
    .Groupable()
    .DataSource(dataSource =>dataSource
        .Server()
        .Total((int)ViewData["total"])
        .Aggregates(aggregates =>
         {
              aggregates.Add(p => p.ShipCountry).Count();
         }
        )
     )
)
0
Angel Petrov
Telerik team
answered on 15 Oct 2019, 01:44 PM

Hi Ray,

A sample implementation on how to configure the grid is provided in this demo. Please examine the setup, apply the approach on your end and let us know how it goes.

Regards,
Angel Petrov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Ray
Top achievements
Rank 1
Answers by
Ray
Top achievements
Rank 1
Angel Petrov
Telerik team
Share this question
or