Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
xamCalculation Custom Summary creation
posted

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! 

Parents Reply Children
No Data