Hi,
I am having a problem getting the column totals updating after a cell has been edited in a RadGridView.
The columns are all (bar one) generated at runtime in the code behind (not MVVM).
My XAML;
<telerik:RadGridView Margin="6"
AutoGenerateColumns="False"
x:Name="dgProducts"
RowIndicatorVisibility="Collapsed"
SelectionUnit="Cell"
IsSynchronizedWithCurrentItem="True"
VerticalGridLinesBrush="#CCC"
HorizontalGridLinesBrush="#CCC"
CanUserInsertRows="False"
CanUserResizeRows="False"
CanUserDeleteRows="False"
ItemsSource="{Binding PromotionVolumes}"
RowHeight="25"
IsFilteringAllowed="False"
ShowGroupPanel="False"
IsReadOnly="{Binding CurrentPromotion.IsReadOnly}"
ScrollMode="RealTime"
Loaded="dgProducts_Loaded"
telerik:StyleManager.Theme="Transparent"
CanUserResizeColumns="True"
ShowColumnFooters="True"
CellEditEnded="dgProducts_CellEditEnded"
CanUserFreezeColumns="False"
>
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Header="Product Name"
DataMemberBinding="{Binding Path=Product.DisplayName}"
Width="170" IsReadOnly="True">
<telerik:GridViewDataColumn.AggregateFunctions>
<telerik:CountFunction Caption="Count: " />
</telerik:GridViewDataColumn.AggregateFunctions>
</telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>
I generate the columns, one for each item in an array of data;
var b = new Binding(string.Format("Measures[{0}].RawValue", i));
var column = new GridViewDataColumn
{
DisplayIndex = i + existingColumnCount,
UniqueName = (i + existingColumnCount).ToString(),
Header = measures[i].Name,
DataMemberBinding = new Binding(string.Format("Item[{0}].Value", i)),
MinWidth = 90,
IsReadOnlyBinding = new Binding(string.Format("Item[{0}].IsReadOnly", i)),
Tag = new Binding(string.Format("Item[{0}].RawValue", i))
};
if (measures[i].IsCalculate)
{
column.DataMemberBinding.Mode = BindingMode.TwoWay;
column.DataMemberBinding.UpdateSourceTrigger = UpdateSourceTrigger.Default;
var sf = new SumFunction() { Caption = "", SourceField = b.Path.Path, SourceFieldType = typeof(decimal), ResultFormatString = "{0:N0}" };
column.AggregateFunctions.Add(sf);
column.AggregateFunctions.Add(aggregate);
}
grid.Columns.Add(column);
When cell editing happens I call;
private void dgProducts_CellEditEnded(object sender, GridViewCellEditEndedEventArgs e)
{
this.dgProducts.Items.CommitEdit();
this.dgProducts.CalculateAggregates();
}
Ordering the grid has no effect on the footer totals either.
I have seen other posts on the forums going back to 2009 and apparently this has been fixed?
What am I missing?
cheers
craig
I am having a problem getting the column totals updating after a cell has been edited in a RadGridView.
The columns are all (bar one) generated at runtime in the code behind (not MVVM).
My XAML;
<telerik:RadGridView Margin="6"
AutoGenerateColumns="False"
x:Name="dgProducts"
RowIndicatorVisibility="Collapsed"
SelectionUnit="Cell"
IsSynchronizedWithCurrentItem="True"
VerticalGridLinesBrush="#CCC"
HorizontalGridLinesBrush="#CCC"
CanUserInsertRows="False"
CanUserResizeRows="False"
CanUserDeleteRows="False"
ItemsSource="{Binding PromotionVolumes}"
RowHeight="25"
IsFilteringAllowed="False"
ShowGroupPanel="False"
IsReadOnly="{Binding CurrentPromotion.IsReadOnly}"
ScrollMode="RealTime"
Loaded="dgProducts_Loaded"
telerik:StyleManager.Theme="Transparent"
CanUserResizeColumns="True"
ShowColumnFooters="True"
CellEditEnded="dgProducts_CellEditEnded"
CanUserFreezeColumns="False"
>
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Header="Product Name"
DataMemberBinding="{Binding Path=Product.DisplayName}"
Width="170" IsReadOnly="True">
<telerik:GridViewDataColumn.AggregateFunctions>
<telerik:CountFunction Caption="Count: " />
</telerik:GridViewDataColumn.AggregateFunctions>
</telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>
I generate the columns, one for each item in an array of data;
var b = new Binding(string.Format("Measures[{0}].RawValue", i));
var column = new GridViewDataColumn
{
DisplayIndex = i + existingColumnCount,
UniqueName = (i + existingColumnCount).ToString(),
Header = measures[i].Name,
DataMemberBinding = new Binding(string.Format("Item[{0}].Value", i)),
MinWidth = 90,
IsReadOnlyBinding = new Binding(string.Format("Item[{0}].IsReadOnly", i)),
Tag = new Binding(string.Format("Item[{0}].RawValue", i))
};
if (measures[i].IsCalculate)
{
column.DataMemberBinding.Mode = BindingMode.TwoWay;
column.DataMemberBinding.UpdateSourceTrigger = UpdateSourceTrigger.Default;
var sf = new SumFunction() { Caption = "", SourceField = b.Path.Path, SourceFieldType = typeof(decimal), ResultFormatString = "{0:N0}" };
column.AggregateFunctions.Add(sf);
column.AggregateFunctions.Add(aggregate);
}
grid.Columns.Add(column);
When cell editing happens I call;
private void dgProducts_CellEditEnded(object sender, GridViewCellEditEndedEventArgs e)
{
this.dgProducts.Items.CommitEdit();
this.dgProducts.CalculateAggregates();
}
Ordering the grid has no effect on the footer totals either.
I have seen other posts on the forums going back to 2009 and apparently this has been fixed?
What am I missing?
cheers
craig