Hi,
I'm currently upgrading UltraWebGrid to WHDG and came across an issue where I need to do sum for a certain column in the grouped rows and show it in the group row summary.
There are functions for [avg], [sum], [min], [max] (either for the grouped column or another column provided by a certain key) for UltraWebGrid, I could not find the same function for WHDG's GroupedRowTextMask.
Is this something I have to do manually or already supported in newer version?
If it's still not supported, I would suggest the functions to be added in future version since it's really helpful.
I'm still on v11.1 and will change to 13.2 after all legacy controls are upgraded.
Thanks,
Charles
Hello Charles,
Currently the GroupedRowTextMask provides the following tokens:
{0} - header of the grouped column, {1} - grouped value, {2} - number of grouped child rows, {3} - number of all data records in the group.
If you need to display some summaries instead of these values you have to create your own custom implementation since this is not provided out of the box. Howevr you can log this as a Product Idea at http://ideas.infragistics.com, the Product Ideas site allows you to suggest new product features, new functionalities in existing products and controls, and even request new controls and products altogether. Members of the Infragistics Community then vote for the features and suggestions they want to see added to the products, resulting in the most popular features bubbling up to the top. When planning new releases, our Product Management team will look at the most popular features and use your feedback to prioritize upcoming work.
* * *
Steps to create your idea:
1. Log into the Infragistics Product Ideas site at http://ideas.infragistics.com (creating a new login if needed).2. Navigate to the product / platform channel of your choice (e.g. WPF, Windows Forms, ASP.NET, HTML5 / Ignite UI, iOS / NucliOS, etc.)3. Add your product idea and be sure to be specific and provide as much detail as possible. Explain the context in which a feature would be used, why it is needed, why it can’t be accomplished today, and who would benefit from it. You can even add screenshots to build a stronger case. Remember that for your suggestion to be successful, you need other members of the community to vote for it. Be convincing!
The benefits of submitting the product idea yourself include:
- Direct communication with our product management team regarding your product idea.- Notifications whenever new information regarding your idea becomes available.
Additional benefits of the product idea system include:- Ability to vote on your favorite product ideas to let us know which ones are the most important to you. You will have ten votes for this and can change which ideas you are voting for at any time.- Allow you to shape the future of our products by requesting new controls and products altogether.- You and other developers can discuss existing product ideas with members of our Product Management team.
The product ideas site allows you to track the progress of your ideas at any time, see how many votes it got, read comments from other developers in the community, and see if someone from the product team has additional questions for you.
Hi Hristo,
Thanks for the quick response. I will submit the idea.
I've tried implementing custom grouping, unfortunately it seems only working for 1st level of grouping.
If I tried to access the 2nd level group or deeper, I get the group row text exactly like what I wanted but it does not show any row data.
Would you please advise if there's anything wrong with the code below?
protected void SetGroupText(GroupedRecord groupedRow) { decimal valTotal = 0; int valRowCount = 0; groupedRow.Rows.Reset(); while (groupedRow.Rows.MoveNext()) { ContainerGridRecord row = (ContainerGridRecord)groupedRow.Rows.Current; WHDGListNode node = row.DataItem as WHDGListNode; TransactionInfo info = (TransactionInfo)node.Item; valTotal += info.Amount; valRowCount++; if (groupedRow.ChildGroupRows.Count > 0) { foreach (GroupedRecord groupedChildRow in groupedRow.ChildGroupRows) { SetGroupText(groupedChildRow); } } } string colName = uiTransactionsGrid.Columns[groupedRow.ColumnGroupedBy.Key].Header.Text; groupedRow.Text = colName + " : " + groupedRow.Value.ToString() + " Count: " + valRowCount.ToString() + " Total: " + valTotal; } protected void uiTransactionsGrid_GroupedRowInitialized(object sender, GroupedRowEventArgs e) { ContainerGrid grid = sender as ContainerGrid; foreach (GroupedRecord groupedRow in grid.GroupedRows) { SetGroupText(groupedRow); } }
Basically whenever I try to access "groupedRow.ChildGroupRows" in SetGroupText method, the grid will only show grouped row headers without any row data.
If I remove any reference accessing "groupedRow.ChildGroupRows", it works fine but the 2nd level group header text is not as expected (it uses the format defined in GroupedRowTextMask instead).
Hi Charles,
Thank you for the updated sample. I managed to ran it although I changed the line where you increase the value of valTotal:
valTotal += System.Convert.ToDecimal(((System.Data.DataRowView)(node.Item)).Row.ItemArray[2].ToString());
(The value column is has index of 2 in the ItemsArray, did it work for you with Row.ItemArray[5] ?! )
Ok I managed to get this look:
which I believe is what you are aiming at - so far so good.
In order to keep on the same track let us discuss from now on:
I see that groupedRow.ChildGroupRows collection is empty, but following your code it seems that you want to call the same function SetGroupText:
foreach (GroupedRecord groupedChildRow in groupedRow.ChildGroupRows) { SetGroupText(groupedChildRow, e); }
Even if this collection is not empty at that point, I doubt that the rows inside will be of the GroupedRecord class, which is expected since you did not grouped based on a column from 2nd level band yet. Also, the columns structure in next level band is different and this approach will fail.
I suggest that before calling the SetGroupText method to check on what column (from which level band does it come ? ) user is trying to group and based on that values to access the proper grouped row and change its text.
I've attached simplified example to use flat data and defined columns in WHDG to make it easier.
Basically, if I'm not accessing "ChildGroupRows" property the grid will display fine but the problem is the 2nd column grouping does not show the header properly on the 2nd column group as image below.
https://drive.google.com/file/d/0B-okqBLdGTTIRksxMzdqWnpCYXM/view?usp=sharing
If I change the code to access and iterate through the "ChildGroupRows" property, I get the expected header for 2nd column group as well, but the row do not display any data:
https://drive.google.com/file/d/0B-okqBLdGTTIemJpVFhDZnBmM2c/view?usp=sharing
So I don't think this has anything to do with what type/class ChildGroupRows is since it can obviously get the values to be calculated correctly nor does it use any band.
It just somehow loses the row data on screen if we touch "ChildGroupRows" property, I've tried 3rd++ column grouping and it gives the expected group headers but no row data is displayed (buttons are in expanded position but no rows there, just like on the last image).
Sorry for the trouble and thank you again. Hopefully it's not something silly on my part!
It seems that you need to check if ChildGroupRows exist as follows:
if (groupedRow.HasChildGroupRows) { foreach (GroupedRecord groupedChildRow in groupedRow.ChildGroupRows) { SetGroupText(groupedChildRow, e); } }
Please try this and let me know if you have further questions on the matter.
Thanks a lot!
That solved the grouping issue.
I was pretty sure I did check the HasChildGroupRows property initially, but since it always return true even for 1st column grouping, I changed it to use Count.
Thanks again!
Thank you for your feedback.
I am glad this helped. Please let me know if you have any further questions on the matter.