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