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
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.
Hi Hristo,
Thank you very much for your assistance.
Attached is the modified zip. I simplified the data for WHDG and added a new column called "Value".
Steps to try:
Trying to access child group rows from a grouped row seems to be the problem. Not quite sure why. I have also tested this on v13.1 and the still the same issue.
Thank you,
Hello Charles,
Thank you for the code shared. It looks ok and I cannot assume what could be wrong and I need to test it. Since I am not quite sure on your scenario I am attaching a sample of WHDG with two level data and grouping enabled. Please modify it to use your code and demonstrate what you have achieved and what is the issue you are struggling with.
I will be glad to investigate and suggest a possible solution for you.
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).
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.