Hello ,
I used SummaryDefinitions with xamdatagrid and had a problem about it.Grid has 4 columns and the third columns is calculated with division second column to first.(it already exists as calculated on entity)
My field definitions like this :
<igDP:Field Name="Column0" Label="Column0" SummaryStringFormats="{}sum: Total"></igDP:Field>
<igDP:Field Name="Column1" Label="Column1" SummaryStringFormats="{}sum: {0:N0}"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource NumericEditorStyle}"></igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="Column2" Label="Column2" SummaryStringFormats="{}sum: {0:N0}"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource NumericEditorStyle}"></igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="Column3" Label="Column3" SummaryStringFormats="{}sum: {0:P0}"> <igDP:Field.Settings> <igDP:FieldSettings> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamNumericEditor}"> <Setter Property="Format" Value="P0"></Setter> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field>
My definitions like this :
<igDP:SummaryDefinition Key="Column1" SourceFieldName="Column1" Calculator="Sum"/> <igDP:SummaryDefinition Key="Column2" SourceFieldName="Column2" Calculator="Sum"/> <igDP:SummaryDefinition Key="Column3" SourceFieldName="Column3" Calculator="Sum"/>
for example :
column1 column2 column3
100 10 %10
70 10 %7
Total 170 20 %17
Total Column3 is %17 ,sum works fine but i wanted to calculate it on summary by 20/170 = %11
To do this i created custom class like this :
public class CustomSummaryCalculator : SummaryCalculator
{
public CustomSummaryCalculator() : base() { }
decimal column1, column2;
public override void BeginCalculation(SummaryResult summaryResult)
column1 = 0;
column2 = 0;
}
public override bool CanProcessDataType(Type dataType)
return dataType == typeof(Decimal);
public override void Aggregate(object dataValue, Infragistics.Windows.DataPresenter.SummaryResult summaryResult, Record record)
if (dataValue != null && (record as DataRecord) != null)
var dataItem = (record as DataRecord).DataItem as MyContract;
if (dataItem != null)
column2 += dataItem.column2; column1 += dataItem.column1;
public override object EndCalculation(Infragistics.Windows.DataPresenter.SummaryResult summaryResult)
return column2 != 0 ? column1 / column2 : 0;
public override string Name { get { return "CustomSum"; } }
public override string Description { get { return "Calculation of Rate"; } }
and then updated summarydefiniton for this column as :
<igDP:SummaryDefinition Key="Column3" SourceFieldName="Column3" Calculator="CustomSummaryCalculator"/>
at last register it on form constructor :
SummaryCalculator.Register(CustomSummaryCalculator);
But it doesn't work,what is wrong about it?
Hello,
Thank you for your post. I have been looking into it I created a sample project for you following your scenario and everything seems to work ok on my side. If the sample doesn’t satisfies all your needs feel free to modify it, so it reproduces your behavior and send it back to me for further investigation.
Looking forward for your reply.
Hello Stefan,
Thank you for reply and example.I edited your example with my scenario and attached.My problem still occurs.
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.
Thank you very much for answer,it works great.
Hello again,
I have been looking into the sample and modified it, so now it works as you want. Basically I chnaged the Name of the Calculator in XAML to "CustomSum" because this is the name of the Calculator. Also I moved the Register of the calculator before the InitializeComponent method, because otherwise it cannot be assigned statically in XAML.Please let me know if this helps you or you need further assistance on this matter.