I have created a custom row summary calculator but do not know how to attach it to a field in the xamDataGrid. I build it and register it in code and then reference it in the xaml as follows:
<igDP:SummaryDefinition
StringFormat=" {0:#,##0.00;(#,##0.00);0.0}"
Key="WorkUnitLaborMult"
SourceFieldName="WorkUnitLaborMult"
Calculator="ProjectEffectiveMult" Position="UseSummaryPositionField"/>
The summary comes up blank when the grid is displayed. Using the debugger I can tell it is not running through the custom calculation class code.
Thank you for your help.
Hello:
I've followed the following to create a custom summary calculator:
http://community.infragistics.com/wpf/wiki/creating-a-custom-summary-for-the-xamdatagrid/1.aspx
http://help.infragistics.com/Help/Doc/WPF/2013.2/CLR4.0/html/xamDataPresenter_Creating_a_Custom_Summary_Calculator.html
and created a trivial custom calculator. I had the same issue as originally stated in this thread. The calculation will only work on the second invocation.
I followed the static property approach suggested by enderrpf and it works, is this the preferred mechanism?
Not working the first time (bind to class) :
<calculators:MySummaryCalculator x:Key="MySummaryCalculator" />
<igDP:SummaryDefinition SourceFieldName="Total" Calculator="MySummaryCalculator" />
MySummaryCalculator.cs:
public override string Name{ get { return "MySummaryCalculator"; }}
Working (bind to static property):
<igDP:SummaryDefinition SourceFieldName="Total" Calculator="{x:Static calculators:MySummaryCalculator.Addition}" />
public static MySummaryCalculator Addition{ get { return _mySummaryCalculator ?? new MySummaryCalculator(); }}
To register in the view.cs;
private void ViewLoaded(object sender, RoutedEventArgs e){ SummaryCalculator.Register(new MySummaryCalculator());}
Thx
Hello Rajib,
You can register your summary calculator in the constructor of the App class, in the App.xaml.cs file.
What is the right place to register SummaryCalculator and declare its static property if we are using MVVM/PRISM?
I set a couple of breakpoints. One in the get property that I set up, and one in the BeginCalculation function of the calculator class. I was able to jump into both of those without any problems.
SummaryDefinition:<igDP:SummaryDefinition Key="PerUnit" SourceFieldName="PerUnit" Calculator="{x:Static Pages:BasePositionPage.MyCalculatorProperty}" StringFormat="{}{0:C}"/>
FieldDefinition:<igDP:UnboundField Name="PerUnit" Label="Unit Cost" Column="15" DataType="{x:Type sys:Decimal}" BindingPath="UnitCost" BindingMode="OneWay"></igDP:UnboundField>
Thank you for your response. Can I see the xaml you used to do the binding? Here is my xaml:
OLD CODE
<!-- <igDP:SummaryDefinition
Calculator="ProjectEffectiveMult" Position="UseSummaryPositionField"/> -->
USING YOUR METHOD
SourceFieldName="myProjectEffectiveMult"
Position="UseSummaryPositionField"/>