We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridGroupingControl SummaryRow

Thread ID:

Created:

Updated:

Platform:

Replies:

68280 Sep 14,2007 01:39 PM Sep 14,2007 02:55 PM Windows Forms 1
loading
Tags: GridControl
James
Asked On September 14, 2007 01:39 PM

For some reason, one of my columns I'm doing a summary on is returning a value of 0. There are quite a few rows that might be 0 but not all of them. See the code I used below to add the summary row.

Dim SummaryRow As GridSummaryRowDescriptor = New GridSummaryRowDescriptor("Summary")
Dim AddedSummaryField As Boolean = False
Dim sc() As GridSummaryColumnDescriptor
For I = 0 To Groups.Length - 1
If Groups(I).FieldName <> Nothing Then
ReDim Preserve sc(I)
sc(I) = New GridSummaryColumnDescriptor(Groups(I).FieldName, SummaryType.DoubleAggregate, Groups(I).FieldName, "{Sum}")
sc(I).Appearance.AnyCell.HorizontalAlignment = GridHorizontalAlignment.Right
sc(I).DisplayColumn = Groups(I).FieldName
SummaryRow.SummaryColumns.Add(sc(I))
AddedSummaryField = True
End If
Next

SummaryRow.Visible = False

If AddedSummaryField Then
Dim OrdersDescriptor As GridTableDescriptor = ggc1.TableDescriptor
OrdersDescriptor.ChildGroupOptions.ShowCaptionSummaryCells = True
OrdersDescriptor.ChildGroupOptions.CaptionSummaryRow = "Summary"
OrdersDescriptor.SummaryRows.Add(SummaryRow)
OrdersDescriptor.ChildGroupOptions.ShowSummaries = False
ggc1.Appearance.GroupCaptionCell.BackColor = ggc1.Appearance.RecordFieldCell.BackColor
ggc1.Appearance.GroupCaptionCell.Borders.Top = New GridBorder(GridBorderStyle.Standard)
'ggc1.Appearance.GroupCaptionCell.Borders.All = New GridBorder(GridBorderStyle.Standard)
ggc1.Appearance.GroupCaptionCell.CellType = "Static"
ggc1.TableOptions.CaptionRowHeight = ggc1.TableOptions.RecordRowHeight
ggc1.TableOptions.SummaryRowHeight = ggc1.TableOptions.RecordRowHeight

If curQuery = "ShortShip" Then
OrdersDescriptor.ChildGroupOptions.ShowSummaries = True
'ggc1.TableDescriptor.ChildGroupOptions.ShowColumnHeaders = True
For X As Integer = 0 To ggc1.TableDescriptor.SummaryRows.Count - 1
ggc1.TableDescriptor.SummaryRows.Item(X).Visible = True
For c As Integer = 0 To ggc1.TableDescriptor.SummaryRows.Item(X).SummaryColumns.Count - 1
ggc1.TableDescriptor.SummaryRows.Item(X).SummaryColumns.Item(c).SummaryDescriptor.IgnoreRecordFilterCriteria = True
ggc1.TableDescriptor.SummaryRows.Item(X).SummaryColumns.Item(c).Style = GridSummaryStyle.Column
ggc1.TableDescriptor.Columns(c).GroupByOptions.ShowSummaries = True
Next
'ggc1.TableDescriptor.SummaryRows.Item(X).SummaryColumns.Count
Next
End If

I put this below code in to return the values...


For Each el As Element In ggc1.Table.DisplayElements
If TypeOf el Is GridSummaryRow Then
Dim sr As GridSummaryRow = TryCast(el, GridSummaryRow)
If sr IsNot Nothing Then
For Each scd As GridSummaryColumnDescriptor In sr.SummaryRowDescriptor.SummaryColumns
Debug.Print("{0} = {1}", scd.Name, GridEngine.GetSummaryText(sr.ParentGroup, scd))

Next
End If
End If
Next

Being that I'm using a DataTable, I added my own summary text that added the value of the column up every time it read the next row in the DataReader. My result was exactly the same as the first summary that is working, but I was able to bring back the correct count with my summary value whereas the built-in summary brings back 0.


GridGroupingControl with a datasource = DataTable.
Using SQL with a DataReader.


James
Replied On September 14, 2007 02:55 PM

Of course I posted prematurely. The column was mispelled.


>For some reason, one of my columns I'm doing a summary on is returning a value of 0. There are quite a few rows that might be 0 but not all of them. See the code I used below to add the summary row.

Dim SummaryRow As GridSummaryRowDescriptor = New GridSummaryRowDescriptor("Summary")
Dim AddedSummaryField As Boolean = False
Dim sc() As GridSummaryColumnDescriptor
For I = 0 To Groups.Length - 1
If Groups(I).FieldName <> Nothing Then
ReDim Preserve sc(I)
sc(I) = New GridSummaryColumnDescriptor(Groups(I).FieldName, SummaryType.DoubleAggregate, Groups(I).FieldName, "{Sum}")
sc(I).Appearance.AnyCell.HorizontalAlignment = GridHorizontalAlignment.Right
sc(I).DisplayColumn = Groups(I).FieldName
SummaryRow.SummaryColumns.Add(sc(I))
AddedSummaryField = True
End If
Next

SummaryRow.Visible = False

If AddedSummaryField Then
Dim OrdersDescriptor As GridTableDescriptor = ggc1.TableDescriptor
OrdersDescriptor.ChildGroupOptions.ShowCaptionSummaryCells = True
OrdersDescriptor.ChildGroupOptions.CaptionSummaryRow = "Summary"
OrdersDescriptor.SummaryRows.Add(SummaryRow)
OrdersDescriptor.ChildGroupOptions.ShowSummaries = False
ggc1.Appearance.GroupCaptionCell.BackColor = ggc1.Appearance.RecordFieldCell.BackColor
ggc1.Appearance.GroupCaptionCell.Borders.Top = New GridBorder(GridBorderStyle.Standard)
'ggc1.Appearance.GroupCaptionCell.Borders.All = New GridBorder(GridBorderStyle.Standard)
ggc1.Appearance.GroupCaptionCell.CellType = "Static"
ggc1.TableOptions.CaptionRowHeight = ggc1.TableOptions.RecordRowHeight
ggc1.TableOptions.SummaryRowHeight = ggc1.TableOptions.RecordRowHeight

If curQuery = "ShortShip" Then
OrdersDescriptor.ChildGroupOptions.ShowSummaries = True
'ggc1.TableDescriptor.ChildGroupOptions.ShowColumnHeaders = True
For X As Integer = 0 To ggc1.TableDescriptor.SummaryRows.Count - 1
ggc1.TableDescriptor.SummaryRows.Item(X).Visible = True
For c As Integer = 0 To ggc1.TableDescriptor.SummaryRows.Item(X).SummaryColumns.Count - 1
ggc1.TableDescriptor.SummaryRows.Item(X).SummaryColumns.Item(c).SummaryDescriptor.IgnoreRecordFilterCriteria = True
ggc1.TableDescriptor.SummaryRows.Item(X).SummaryColumns.Item(c).Style = GridSummaryStyle.Column
ggc1.TableDescriptor.Columns(c).GroupByOptions.ShowSummaries = True
Next
'ggc1.TableDescriptor.SummaryRows.Item(X).SummaryColumns.Count
Next
End If

I put this below code in to return the values...


For Each el As Element In ggc1.Table.DisplayElements
If TypeOf el Is GridSummaryRow Then
Dim sr As GridSummaryRow = TryCast(el, GridSummaryRow)
If sr IsNot Nothing Then
For Each scd As GridSummaryColumnDescriptor In sr.SummaryRowDescriptor.SummaryColumns
Debug.Print("{0} = {1}", scd.Name, GridEngine.GetSummaryText(sr.ParentGroup, scd))

Next
End If
End If
Next

Being that I'm using a DataTable, I added my own summary text that added the value of the column up every time it read the next row in the DataReader. My result was exactly the same as the first summary that is working, but I was able to bring back the correct count with my summary value whereas the built-in summary brings back 0.


GridGroupingControl with a datasource = DataTable.
Using SQL with a DataReader.



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;