Hello,
I am somewhat still new to WPF, and I am inquiring about completing a custom summary in a xamDataGrid which contains 3 columns, A (quantity), B (Cost), C(List Price).
My goal is to multiply A * B, and have the calculation summary for column B reflect at the bottom in the Summary Definition, and do the same by multiplying A * C, and also have that summary reflected at the bottom in the summary definition for column C.
Below is what I have so far.
public class DataGridCustomSummary : SummaryCalculator {
private int _numTickets; private decimal _cost; private decimal _listPrice; private decimal _costTotal; private decimal _listPriceTotal;
public override void BeginCalculation(SummaryResult summaryResult) {
_numTickets = 0; _listPrice = 0; _cost = 0;
}
public override bool CanProcessDataType(Type dataType) { return Utilities.IsNumericType(dataType); }
public override void Aggregate(object dataValue, SummaryResult summaryResult, Record record) { decimal myCellValue = decimal.Parse(dataValue.ToString()); DataRecord myCurrentRecord = record as DataRecord;
if (myCellValue > _costTotal) {
_costTotal = _numTickets * _cost; _listPrice = _numTickets * _listPrice; _costTotal = myCellValue; _listPriceTotal = myCellValue;
} }
public override object EndCalculation(SummaryResult summaryResult) { return _costTotal; }
public override string Name { get { return "Cost Total"; } }
public override string Description { get { return "Cost Total"; } } }
Thanks in advance for your assistance!
Hello Brian, Thank you for contacting Infragistics. We provide our own CalculationManager component that can be integrated with the XamDataChart for building custom summaries. I attached a sample below which will help you get started with this task.
1. The Field Layout of the XamDataGrid contains a SummaryDefinition with a built SummaryCalculationSettings to define a formula which you can use to display the calculation summary for column B as you've described.
eg.
<igDP:FieldLayout.SummaryDefinitions> <igDP:SummaryDefinition Position="Left" Key="Multiple A * B"> <igDP:SummaryDefinition.CalculationSettings> <igDP:SummaryCalculationSettings Formula="Sum([A] * [B])" ReferenceId="Column B" /> </igDP:SummaryDefinition.CalculationSettings> </igDP:SummaryDefinition> </igDP:FieldLayout.SummaryDefinitions>
I recommend reviewing the following help article that walks through this entire process.
http://www.infragistics.com/help/wpf/xamcalculationmanager-using-xamcalculationmanager-with-xamdatagrid
Please review the sample attached for more details. Let me know if you have any questions.
Good Morning Micheal,
Thanks. That helped tremendously with completing this task at hand.
Much appreciated!
Hello Brian,
Thank you very much for you reply. Let me know if there is anything else I can assist you with.