Unplanned
Last Updated: 07 Jun 2020 17:01 by ADMIN
ANDREW
Created on: 07 Jun 2020 16:59
Category: Grid
Type: Bug Report
3
Aggregates don't work with nested properties

Group by the third column - there will be no aggregate info:

    <TelerikGrid Data="@myData" Pageable="true" Sortable="true" FilterMode="@GridFilterMode.FilterRow" Groupable="true">
        <GridColumns>
            <GridColumn Field="@nameof(SampleComplexObject.ID)" Title="ID"></GridColumn>
            <GridColumn Field="@nameof(SampleComplexObject.Name)" Title="The Name"></GridColumn>
            <GridColumn Title="First Nested Property" Field="SomeNavigationProperty.Field1">
                <GroupFooterTemplate>
                   Count: @context.Count
                </GroupFooterTemplate>
            </GridColumn>
            <GridColumn Field="SomeNavigationProperty.OtherField" />
        </GridColumns>
        <GridAggregates>
            <GridAggregate Field="SomeNavigationProperty.Field1" Aggregate="@GridAggregateType.Count" />
        </GridAggregates>
    </TelerikGrid>


@code {
    public class SampleComplexObject
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public NestedObject SomeNavigationProperty { get; set; } // use this field name for data binding
    }

    public class NestedObject
    {
        public string Field1 { get; set; }
        public string OtherField { get; set; }
    }

    public IEnumerable<SampleComplexObject> myData = Enumerable.Range(1, 50).Select(x =>
            new SampleComplexObject
            {
                ID = x,
                Name = "Name " + x,
                SomeNavigationProperty = new NestedObject
                {
                    Field1 = "first " + x % 4,
                    OtherField = "second " + x % 6
                }
            }
        );
}

0 comments