Hi,
would it be possible to retemplate the summary picker on the xamdatagrid to add a custom summary? Our users would like the ability to add a weighted average to a column. Therefore the summary picker would need to expose a "Weighted Average" check box along with a drop down next to it of all the other fields in the grid so that the user can select the field that will supply the weighting.
thanks
Hello Alan,
I have been investigating into a way that you could create a weighted summary on a particular Field, and I would recommend that you take a look at our online documentation about calculated external summaries in the XamDataGrid here: http://help.infragistics.com/Help/Doc/WPF/2012.1/CLR4.0/html/Using%20xamCalculationManager%20with%20xamDataGrid.html.
I have also created a sample project that demonstrates one way you could achieve the requirement you are looking for. To start, I would recommend including the default style for SummaryButton in your project. This default style can commonly be found in the xaml file at the following directory: C:\Program Files (x86)\Infragistics\2015.1\WPF\DefaultStyles\DataPresenter\DataPresenterGeneric_Express. In the default template within this default style, there is a Button named "RowSummaryOkButton" I would recommend that you hook into the Click event on this Button. You will also need the default template for the SummaryCalculatorSelectionControl, which is the element that holds the checkboxes that you use to add summaries to the XamDataGrid Fields. This default template can be found in the same file mentioned above.
If you write a Style for the SummaryCalculatorSelectionControl, you can create a DataTrigger that checks the Field that this element exists on. If it is the field that you wish to apply your custom summary on, you can modify the Template of this SummaryCalculatorSelectionControl to include your own custom checkbox, TextBlock, and XamComboEditor which is bound to the Fields collection of the FieldLayout that your Field exists in. It just so happens that the data context of the SummaryCalculatorSelectionControl is that FieldLayout, so you can use the following binding for the ItemsSource of the XamComboEditor in your custom template: {Binding Fields}.
Earlier on, I recommended that you should hook into the Click event on the "RowSummaryOkButton." From this button, you can obtain the checkbox and the XamComboEditor that you have placed in the template by using the Infragistics.Windows.Utilities class and its static GetAncestor/Descendant methods. The next step will be to follow step 7e of the online documentation article I recommended at the start and construct a SummaryDefinition with your formula to create a Weighted Average.
I have attached a sample project to demonstrate the above. I hope this helps you.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
thanks, that article is useful. Unfortunately it will not satisfy my requirements because for a weighted average I need the ability to specify the column that will provide the weighting.
Suppose I had an "Interest Rate" column and a "Quantity" column and I wanted to display a weighted average rate on the "Interest Rate" column weighted against the "Quantity". I don't want to hardcode it because this needs to be generic. Therefore the user needs the ability to specify the column to use as the weighting. Ideally this would be done inside the summary picker when they are adding summaries to the "Interest Rate" field. Is this possible?
Alan
Thank you for your post.
While you can retemplate the summary picker on the XamDataGrid to add a custom summary, this really isn't necessary as the XamDataGrid exposes functionality to do this out-of-the-box. I would recommend you take a look at this article in our online documentation about creating a custom summary in the XamDataGrid: http://help.infragistics.com/Help/Doc/WPF/2013.2/CLR4.0/html/xamDataPresenter_Creating_a_Custom_Summary_Calculator.html.