Hi,
We recently gave a few users the ability to auto group by on a xamdatagrid(previously we made separate custom grids of each of these) and they liked the feature.
The columns in the grid are customer, supplier, product, price_req, qty_req, qty_bought, price_bought, sale(bool)
Any any time the user wants to be able to group by either of customer, supplier, product and in the collapsed groups in the grid want to see the sum(qty_req) and avg(price_req) and %sale(no of Yes/No).
Thus we need help with two questions.
1) Is it possible to limit the columns that can be used to group by?
2) Is it possible to customize the look of the group by header area to include aggregate information from its corresponding subset of data? Is there an example you can point me to?
Thanks in advance for your help with this?
Hi Devaprem,
The templates are installed along with the product so you should be able to access them from your Infragistics installation directory. The specific directory for XamDataGrid templates can be found here: C:\Program Files (x86)\Infragistics\2015.1\WPF\DefaultStyles\DataPresenter
Great this was perfect for me.
On a related note. Is there a place I can look for the templates of the various controls which I can going forward take a look at myself to make such changes? Is this available online?
It's possible to change this but it's not a straight forward approach. The GroupByRecord header is coded to display the summary text as <field> <summary text> and while it's possible to change the summary text using the StringFormat property on the SummaryDefinition it will still append the field name at the front. So what I did was to retemplate the GroupByRecordPresenter and change the part of the template that renders the summary text. Using a converter I take the summary values and display them in the required format.
There is some extra stuff I needed to add as well. For example, I need to know when the summary value is changed so I can update the custom summary text. I also need to know when summaries are removed. For this I handled the SummaryResultChanged event and the SummarySelectionControlClosed event. The SummarySelectionControlClosed event has an argument that tells us if the summaries have actually changed. This is useful for determining if summaries were removed.
I attached a sample containing the necessary code. Let me know if you have any questions on this.
Hi Rob,
Thanks for your reply. I was able to get this working using the examples you provided. However, I have a followup question on this.
The default layout for showing the values in the GroupByRecordPresenter seems to be <column_name group_by_operation = computed_value> E.g Qty Sum = 2,000,000
I want to be able to format displayed string to be something like <group_by_operation(column_name): formatted_computed_value>. E.g Sum(Qty): 2M.
Is there a way this can be done.
Again, thanks in advance for your help.
I believe the sample you are looking for can be found in the WPF samples browser that we provide. There is a sample under xamDataGrid -> Organization -> Summary Location and UI Type which shows you the different places you can place the summaries. One of those places is the GroupBy headers for each group. Summaries displayed here will show the aggregate values for all records that fall within the group.
For limiting columns that can be used for grouping, there is a property on the Field class called AllowGroupBy. If you set this to false the column will not be allowed to groupby. Set this property on each Field that you wish to restrict.
Let me know if you have any questions on this.