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

GroupFooterTemplate doesn't work with serverside grouping

1 Answer 217 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bert
Top achievements
Rank 1
Veteran
Bert asked on 01 Apr 2021, 10:43 AM

Hi,

I'm using the OnRead Event to do server side grouping and filtering. This is the function I use to retrieve the data:

DataSourceResult Result;
                if (_Request.Groups.Count > 0)
                {
                    argsCloned.Groups.Clear();
                    Result = await queriableData.ToDataSourceResultAsync(argsCloned);
                }
                else
                    Result = await queriableData.ToDataSourceResultAsync(_Request);


                DataEnvelope<T> dataToReturn = null;
                if (_Request.Groups.Count > 0)
                {
                    // Group again => Do grouping on local data
                    if (Result.Data != null)
                    {
                        Result = await Result.Data.ToDataSourceResultAsync(_Request);

                        dataToReturn = new DataEnvelope<T>
                        {
                            GroupedData = Result.Data.Cast<AggregateFunctionsGroup>().ToList(),
                            TotalItemCount = Result.Total
                        };
                        _GridData = dataToReturn.GroupedData.Cast<object>().ToList();
                    }
                }
                else
                {
                    dataToReturn = new DataEnvelope<T>
                    {
                        CurrentPageData = Result.Data.Cast<T>().ToList(),
                        TotalItemCount = Result.Total
                    };
                    _GridData = dataToReturn.CurrentPageData.Cast<object>().ToList();

                }

 

This works fine, the grouping is done and the aggregate data seems to be correct. But I don't see the data in the GroupFooterTemplate. If I Put a breakpoint inside the GroupFooterTemplate, the breakpoint is never hit.

<GridAggregates>    
                <GridAggregate Field="@nameof(TblCarrier.CarArtUid)" Aggregate="@GridAggregateType.Count" />
                <GridAggregate Field="@nameof(TblCarrier.CarQty)" Aggregate="@GridAggregateType.Sum" />
                <GridAggregate Field="@nameof(TblCarrier.CarWeightNetto)" Aggregate="@GridAggregateType.Sum" />
            </GridAggregates>

            <GridColumns>
                <GridColumn Field="@nameof(TblCarrier.CarUid)" FieldType="@(typeof(long))" Title="Uid" Width="150" Editable="false" Filterable="true">
                </GridColumn>

                <GridColumn Field="@nameof(TblCarrier.CarBarcode)" FieldType="@(typeof(long))" Title="Barcode" Width="150" Editable="false" Filterable="true"/>
                <GridColumn Field="@nameof(TblCarrier.CarTsCreation)" FieldType="@(typeof(DateTime))" Title="Ts Created" DisplayFormat="{0:dd/MM/yyyy HH:mm:ss.fff}" Width="200" Editable="false" Filterable="true"/>
                <GridColumn Field="@nameof(TblCarrier.CarTsLastMove)" FieldType="@(typeof(DateTime))" Title="Ts Moved" DisplayFormat="{0:dd/MM/yyyy HH:mm:ss.fff}" Width="200" Editable="false" Filterable="true"/>      
                <GridColumn Field="@nameof(TblCarrier.CarDescription)" FieldType="@(typeof(string))" Title="Description" Width="200" Editable="@(this.RoleLevel>=eRoles.Administrator)"  Filterable="true"/>
                <GridColumn Field="@nameof(TblCarrier.CarArtUid)" FieldType="@(typeof(string))" Title="Article ID" Width="200" Editable="@(this.RoleLevel>=eRoles.Developer)" Filterable="true">
                    <GroupHeaderTemplate>
                        @{
                            // you can use aggregates for other fields/columns by extracting the desired one by its
                            // field name and aggregate function from the AggregateResults collection
                            // The type of its Value is determined by the type of its field - decimal for the Salary field here
                            var ctx = context as GridGroupTemplateContext;
                            
                        }
                        Team Members: <strong>@context.Count</strong>
                    </GroupHeaderTemplate>      
                    <GroupFooterTemplate>
                        @{
                            // you can use aggregates for other fields/columns by extracting the desired one by its
                            // field name and aggregate function from the AggregateResults collection
                            // The type of its Value is determined by the type of its field - decimal for the Salary field here
                            var ctx = context as GridGroupTemplateContext;
                            
                        }
                        Team Members: <strong>@context.Count</strong>
                    </GroupFooterTemplate> 
                </GridColumn>

Best Regards

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 01 Apr 2021, 01:14 PM

Hi Bert,

At the moment, the framework cannot serialize interfaces, so the IDictionary that contains the aggregate data on the server does not reach the browser. You can read a bit more about this, and follow a potential improvement here: https://feedback.telerik.com/blazor/1495388-allow-serializing-and-deserializing-grid-aggregates-with-server-grouping. We discussed this with you in early January.

 

 

Regards,
Marin Bratanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid
Asked by
Bert
Top achievements
Rank 1
Veteran
Answers by
Marin Bratanov
Telerik team
Share this question
or