Hello all,
i would like to set up to SummaryDefinition in the control xamdataGrid as follow :
1 - the First one 'Count' the total of records where the value of the cell "CODE" is not empty ;
2 - The second one 'Count' the total of records where the value of cell "CODE" is empty ;
i am asking if there is any example related to my task or something similar .
Thanks
jay
Hello gerryjj,
Thank you for your feedback.
I am glad to know that I was able to help you achieve the functionality you were looking for. I believe this thread can help other people looking for a similar solution.
If you have any questions, please let me know.
Dear Tacho,
it is so kind by you to attach also an example, in fact ii works great.
Thanks so much
Cheers
Thank you for the SummaryDefinitions' descriptions you have provided.
In order to apply a summary definition that calculates the count of empty and not empty cell values for a specific field based on all the records, I can suggest you create a couple of custom summary calculators that inherit the SummaryCalculator abstract class and implement the necessary methods.This way by registering them prior to the InitializeComponent method in the window's constructor, you will be able to reference the custom calculators in your application by using their implemented Name property.
XAML:
<igDP:FieldLayout.SummaryDefinitions> <igDP:SummaryDefinition Calculator="EmptyCount" SourceFieldName="Code" /> <igDP:SummaryDefinition Calculator="NotEmptyCount" SourceFieldName="Code" /></igDP:FieldLayout.SummaryDefinitions>
Code-behind:
// Implementation is analogical for the NotEmptySummaryCalculator
public class EmptySummaryCalculator : SummaryCalculator{ private int emptyRecordValuesCount; public EmptySummaryCalculator() : base() { } public override void BeginCalculation(SummaryResult summaryResult) { emptyRecordValuesCount = 0; } public override bool CanProcessDataType(Type dataType) { return dataType == typeof(string); } public override void Aggregate(object dataValue, Infragistics.Windows.DataPresenter.SummaryResult summaryResult, Record record) { if (dataValue != null && (record as DataRecord) != null && dataValue.ToString() == string.Empty) { emptyRecordValuesCount++; } } public override object EndCalculation(Infragistics.Windows.DataPresenter.SummaryResult summaryResult) { return emptyRecordValuesCount; } public override string Name { get { return "EmptyCount"; } } public override string Description { get { return "Calculation of empty values"; } }}
public override void BeginCalculation(SummaryResult summaryResult) { emptyRecordValuesCount = 0; }
public override bool CanProcessDataType(Type dataType) { return dataType == typeof(string); }
public override void Aggregate(object dataValue, Infragistics.Windows.DataPresenter.SummaryResult summaryResult, Record record) { if (dataValue != null && (record as DataRecord) != null && dataValue.ToString() == string.Empty) { emptyRecordValuesCount++; } }
public override object EndCalculation(Infragistics.Windows.DataPresenter.SummaryResult summaryResult) { return emptyRecordValuesCount; }
public override string Name { get { return "EmptyCount"; } } public override string Description { get { return "Calculation of empty values"; } }}
I have attached a sample application that demonstrates the approach from above.
For more detailed information on creating custom summary calculators, I can suggest you look at the following topic.