When we edit any cell and go to other cell of the same row, it doesn't update the aggregate on the footer. When we go to other row it update the footer aggregate.
How can we make the aggregate update automatically after cell edit commit, not on row edit commit?
Thanks
Hrushikesh Patel
8 Answers, 1 is accepted
You may try to handle the CellEditEnded event of RadGridView and call the CalculateAggregates() method. For example:
private void playersGrid_CellEditEnded(object sender, GridViewCellEditEndedEventArgs e)
{
this.playersGrid.CalculateAggregates();
}
Greetings,
Maya
the Telerik team
Now we are having another but very similar issue. If we performed grouping and change any cell value, on Lost focus it successfully update the group footer but again we are not having each row footer at the same time, however while we click on another row, it updates the row footer correctly. Please find attached screen for better understanding.
Please suggest what we need to do in order to update each row footer at the same time.
Thanks,
Sumit
Unfortunately, I am not quite capable of understanding your exact scenario. Please, provide a bit more specifics about the steps you are making and the desired/undesired behavior of the aggregate functions.
Maya
the Telerik team
Previously you suggested that we need to add CalculateAggregates() on CellEditEnded event and it was working. But If we have applied grouping on that Grid and we have added Group Row Footer, its not working for GroupRowFooter.
private void playersGrid_CellEditEnded(object sender, GridViewCellEditEndedEventArgs e)
{
this.playersGrid.CalculateAggregates();
}
Below you can see the code used for binding and implementing the functionality of changing the grouped-by element.
private void OnLoaded(object s, RoutedEventArgs e)
{
this.dayColumns = this.CreateDayColumns();
this.CreateGroup(ClientFullNameLabel, ClientLabel);
}
private IEnumerable<GridViewColumn> CreateDayColumns()
{
var temp = new List<GridViewColumn>();
foreach (var gridColumn in from column in ((IDayColumnsViewModel)this.ViewModel).DayColumns
select new RadNumericUpDownColumn()
{
IsVisible = column.IsVisible,
Header = column.Header,
DataMemberBinding = new Binding(column.BoundPropertyName),
IsFilterable = false,
IsGroupable = true,
UniqueName = column.UniqueName,
CellTemplateSelector = new DayCellDataTemplateSelector(column.BoundPropertyName)
})
{
SumFunction sumFunction = new SumFunction();
sumFunction.SourceField = gridColumn.UniqueName;
sumFunction.ResultFormatString = "{0:f2}";
gridColumn.AggregateFunctions.Add(sumFunction);
this.grdView.Columns.Add(gridColumn);
temp.Add(gridColumn);
}
return temp;
}
private void GroupByComboSelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
{
// Combo selection occured before the grid was ready
if (this.grdView == null) return;
var item = (RadComboBoxItem)e.AddedItems[0];
var member = string.Empty;
var displayContent = string.Empty;
switch (item.Content.ToString())
{
case ClientLabel:
member = ClientFullNameLabel;
displayContent = ClientLabel;
break;
case FundIdentifierLabel:
member = FundIdentifierUuidLabel;
displayContent = FundIdentifierLabel;
break;
case ServiceLabel:
member = ServiceUuidLabel;
displayContent = ServiceLabel;
break;
}
if (member == string.Empty)
{
//Remove grouping
this.grdView.GroupDescriptors.Clear();
}
else
{
// Adds grouping to the grid
this.CreateGroup(member, displayContent);
}
}
private void CreateGroup(string member, string displayContent)
{
this.grdView.GroupDescriptors.Clear();
var descriptor = new Telerik.Windows.Data.GroupDescriptor();
descriptor.Member = member;
descriptor.SortDirection = ListSortDirection.Ascending;
descriptor.DisplayContent = displayContent;
AggregateFunction func = new SumFunction { SourceField = "TotalUnits", ResultFormatString = "Total units: {0:f}" };
descriptor.AggregateFunctions.Add(func);
var column = this.grdView.Columns["TotalUnits"];
column.AggregateFunctions.Clear();
column.AggregateFunctions.Add(func);
func = new CountFunction { ResultFormatString = "Total clients: {0}" };
descriptor.AggregateFunctions.Add(func);
column = this.grdView.Columns["ClientFullName"];
column.AggregateFunctions.Clear();
column.AggregateFunctions.Add(func);
foreach
(var item in this.grdView.Columns.Where<GridViewColumn>(c => c.UniqueName != null && c.UniqueName.StartsWith("Day")))
{
SumFunction sumFunction = new SumFunction();
sumFunction.SourceField = item.UniqueName;
sumFunction.ResultFormatString =
"{0:f2}";
descriptor.AggregateFunctions.Add(sumFunction);
item.AggregateFunctions.Clear();
item.AggregateFunctions.Add(sumFunction);
}
this.grdView.GroupDescriptors.Add(descriptor);
}
<r:RadGridView.Columns>
<r:GridViewDataColumn Header="Client" DataMemberBinding="{Binding Path=ClientFullName}" UniqueName="ClientFullName" IsReadOnly="True" >
<r:GridViewDataColumn.AggregateFunctions>
<telerik:CountFunction ResultFormatString="{}Total clients: {0}" />
</r:GridViewDataColumn.AggregateFunctions>
</r:GridViewDataColumn>
<local:RadNumericUpDownColumn Header="Total Units" DataMemberBinding="{Binding Path=TotalUnitsUi, Mode=TwoWay}" CellTemplateSelector="{StaticResource itemModifiedSelector}" UniqueName="TotalUnits" IsFilterable="False">
<local:RadNumericUpDownColumn.AggregateFunctions>
<telerik:SumFunction SourceField="TotalUnits" ResultFormatString="{}Total units: {0:f}" />
</local:RadNumericUpDownColumn.AggregateFunctions>
</local:RadNumericUpDownColumn>
</r:RadGridView.Columns>
Hope this would help you in better understanding the Grid and Grouping functionality we have implemented.
Now find out the previously attached Screednshot. In that as we change any cell value, Grid Footer is updated but not the Group Row Footer.
Thanks,
Sumit
The fact that the Aggregate Results are not updated in the Group Footer is a know issue and we are working on its fix. You may follow up its progress in our Public Issue Tracking System by its ID - 2970 or directly through this link.
Maya
the Telerik team
Is this issue solved?
I cant find it in your issue tracker.
Regards
/Fredrik
The issue has been resolved. Please, try our latest internal build - version 2011.2.1024.
Here is the PITS issue link.
Best wishes,
Yordanka
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>