I'm planning to do the totals/aggregate function at code behind. do you've any sample codes for this?
My code:
GridViewDataColumn gridColumn = new GridViewDataColumn{Header = key};
Binding bin = new Binding(string.Format("Key.Attributes[{0}]", key));
gridColumn.DataMemberBinding = bin;
TraderMeasureSeriesGrid.Columns.Add(gridColumn);
I would like to attach
AggregateFunctions from code behind. how can I set this?<telerik:GridViewDataColumn.AggregateFunctions>
<telerik:SumFunction Caption="Sum: " SourceField="TotalCost" FunctionName="Sum" />
</telerik:GridViewDataColumn.AggregateFunctions>
<telerik:GridViewDataColumn.Footer>
<telerik:RadButton Content="Show smallest UnitPrice" Click="Button_Click" Margin="5,0" />
</telerik:GridViewDataColumn.Footer>
<telerik:GridViewDataColumn.GroupHeaderTemplate>
<DataTemplate>
<TextBlock Foreground="Green" Text="{Binding Group.Key}" />
</DataTemplate>
</telerik:GridViewDataColumn.GroupHeaderTemplate>
Thanks in advance,
9 Answers, 1 is accepted
You can set it exactly in the same way as in XAML. Just create desired function and add it in the column aggregate functions.
Greetings,Vlad
the Telerik team
Thanks
You should create SumFunction exactly as in XAML.
Best wishes,Vlad
the Telerik team
I tried all possible scenarios hence posted this question. if it's same as xaml, can you attach code snippet? we're evaluating Telerik versus DevExpress controls. you quick response will be appreciated.
Thanks
Here is the code - extremely simple as you can see:
var column = new GridViewDataColumn();
column.AggregateFunctions.Add(new SumFunction() { SourceField = "YourSourceFiled" });
Vlad
the Telerik team
When I do the following I get zero sum:
gridColumn.AggregateFunctions.Add(new SumFunction() {SourceField = measure,FunctionName = "Sum", SourceFieldType = Type.GetType("System.Int32")});
do you know why? no exception no error simply zero. Please note that I'm not using any other celltemplate, footer or header templates:
GridViewDataColumn gridColumn = new GridViewDataColumn {Header = measure};
gridColumn.DataMemberBinding = bin;
gridColumn.AggregateFunctions.Add(new SumFunction() {SourceField = measure,FunctionName = "Sum", SourceFieldType = Type.GetType("System.Int32")});
TraderMeasureSeriesGrid.Columns.Add(gridColumn);
Please let me know how to debug Aggregate functions like above to check where I'm going wrong.
Thanks
