Good evening.how do I display the sum of a column in a XDataGrid?Thank you.
I write this in the xDataGrid1_Load event:
XamDataGrid xdg = sender as XamDataGrid;SummaryDefinitionCollection summaries = xdg.FieldLayouts[0].SummaryDefinitions;summaries.Clear();SummaryDefinition summary = new SummaryDefinition();summary.Calculator = SummaryCalculator.Sum;summary.SourceFieldName = "CassaUscita";summaries.Add(summary);
the first start I get this error on line SummaryDefinitionCollection summaries = xdg.FieldLayouts[0].SummaryDefinitions; :Index out of range. Required non-negative value and the size of the nomire.if I close the contentPane where you uploaded the UserControl that contains the XDataGrid and then reopen, I receive the money without any problems.XDataGrid the UserControl is in a load in a contentPane.
with that first code works well.I missed the code that loads the UserControl in ContentePane.Thank you.
I was wrong. I have not solved.I noticed that the problem is because the XDataGrid and bind in XAML and when the UserControl is loaded, the source data is still empty. It also triggers the launch of the UserControl the event is not the xDataGrid1_Load Filed [0] and generates the error.What should I use instead of the Load XDataGrid?
Hello Pranzo,
It has been a while since you have made your post, in case you still need support I will be glad to assist you further. I suppose the other community members can benefit from this answer as well. I have been looking into your post and I suggest you set the summary in XAML instead of code – behind, like it is described here:
http://help.infragistics.com/NetAdvantage/WPF/2011.1/CLR4.0/?page=xamDataPresenter_Programmatically_Add_Summaries_to_a_Field.html
Feel free to write me if you have further questions.