I have a grid that the user can choose to populate with up to 17 columns. They can also choose to group by any of the selected columns. My grid is torn down and rebuilt from scratch in code each time the user changes their column and grouping selection. Reading through the knowledge base and other peoples questions I have managed to get group footer summaries working. What I can not quite get to work is custom text on the group summary. I have attached a picture of what I have achieved so far, and what I would like to achieve. Lets say you have category and that category has three sub-categories. I can get the group summary to say "sub-category1, sub-category2, sub-category3" but when drop back to the category level, it displays sub-categoty3 in the summary?
This is the code I am using to build my custom group summary on the fly;
Dim item1 As GridGroupSummaryItem = New GridGroupSummaryItem()
item1.FieldName = ProductionView.Columns(0).FieldName
item1.SummaryType = DevExpress.Data.SummaryItemType.Custom
item1.ShowInGroupColumnFooter = ProductionView.Columns(0)
item1.Tag = "Process Me"
ProductionView.GroupSummary.Add(item1)
And this is the code I use to process the group summary;
Private Sub ProductionView_CustomSummaryCalculate(ByVal sender As Object, ByVal e As DevExpress.Data.CustomSummaryEventArgs) Handles ProductionView.CustomSummaryCalculate
If e.SummaryProcess = DevExpress.Data.CustomSummaryProcess.Finalize AndAlso (CType(e.Item, GridGroupSummaryItem)).Tag.Equals("Process Me") Then
e.TotalValue = (TryCast(sender, GridView)).GetGroupRowValue(e.RowHandle)
End If
End Sub
I know it's probably not the way this should be done, but it's the best I could do using the learn as you go approach.
Can you see were I am going wrong? Am I approaching this all wrong? I have read, and read through the articles on this site but cant figure out it is that I am not doing right?
Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Hi Marcus,
To solve this problem, please handle the CustomDrawFooterCell event. Some sample code can be found in the CustomDraw module of the GridMainDemo project.
Please review the How to display a group row value in a group footer summary cell example.
Thanks,
Andrew
I am not very happy Andrew. I feel pretty much like you have not paid any attention to what I have tried to explain at all. When you point me to a project the has the exact code I have posted it makes me wonder if I am going to get a resolve for this all?
Number 1.
The project you suggested as a starting point to solving my problem contains the exact code I posted. I admit I changed .tag="1" to .tag="Process Me".
Number 2.
The project you suggested has exactly the same problem as I am facing. Using your example project;
Group by Customer ID and OrderID you will now see that both the customer group summary and the OrderID group summary contain the OrderID.
The project CustomerID Group summary should contain the customerID, and the orderID summary to contain the orderID.
Number 3.
Your suggestion to handle the CustomDrawFooterCell event. The project you suggested does not contain any reference whatsoever to the CustomDrawFooterCell event.
Number 4.
As far as I understand because I use the componentlink to print custom drawing is not an option.
I have included another picture, this time of the project you suggested so maybe you can see the problem.
This would be expected behaviour;
Category Header
subCat1 Header
subCat1 Footer
SubCat2 Header
SubCat2 Footer
Category Foot
This is what I am getting in my code and in the example project;
Category Header
subCat1 Header
subCat1 Footer
SubCat2 Header
SubCat2 Footer
SubCat2 Footer
I am thinking that maybe I got hold you when It was really late and you were not thinking clearly? Maybe the next response may be at least a little helpful.
Hi Marcus,
Thank you for the response. Indeed, it seems that we didn't completely understand your requirements. Please modify the gridView1_CustomSummaryCalculate method of example E307 as follows:
private void gridView1_CustomSummaryCalculate(object sender, DevExpress.Data.CustomSummaryEventArgs e) { GridView gv = (GridView)sender; if (!e.IsGroupSummary) return; if (e.SummaryProcess == DevExpress.Data.CustomSummaryProcess.Finalize && Equals(((GridGroupSummaryItem)e.Item).Tag, 1)) { e.TotalValue = gv.GetGroupRowValue(e.RowHandle, gv.GroupedColumns[e.GroupLevel]); } }
Private Sub gridView1_CustomSummaryCalculate(ByVal sender As Object, ByVal e As DevExpress.Data.CustomSummaryEventArgs) Dim gv As GridView = CType(sender, GridView) If (Not e.IsGroupSummary) Then Return If e.SummaryProcess = DevExpress.Data.CustomSummaryProcess.Finalize AndAlso Equals((CType(e.Item, GridGroupSummaryItem)).Tag, 1) Then e.TotalValue = gv.GetGroupRowValue(e.RowHandle, gv.GroupedColumns(e.GroupLevel)) End If End Sub
To left-align the footer cell contents, set the GridView.Appearance.GroupFooter.TextOptions.HAlignment property to Near.
Please let us know if this helps.
Thanks,
Michael.
Thanks very much for the reply. The result was excellent, exactly what I was after.
Now that issue can be put to rest.
I have attached a picture of another and hopefully the last issue I am having with the grid.
I am not sure though whether I should create another Question or not?
Anyway, as you will see in the picture, my grid is on the left and a preview of the grid is on the right.
The preview is create using a componentlink printpreview dialgog in ribbon mode.
The preview does not align the group footers left.
But the main problem really, is the merged cells are way wrong.
merging seems to happen for two rows max then it unmerges and merges another two, then unmerges does another two etc etc
Any ideas?
Thanks again for the previous help it was excellent.
Hi Marcus,
To left-align a group footer text in a printed document, set the GridView.AppearancePrint.GroupFooter.TextOptions.HAlignment property to Near, and set the GridView.OptionsPrint.UsePrintStyles property to True.
As for the cell merging issue, I'm afraid I can't reproduce it on my side. I've attached a sample project that works fine for me. Please modify it to reproduce the issue, and attach it to your next post.
Thanks,
Michael.