Articles in this section
Category / Section

How to summary results on the inner most table be displayed on every parent level in the WinForms GridGroupingControl with nested related tables?

2 mins read

Summaries

Generally, summary values are displayed in the summary row. To view the summary value of a nested table, you need to expand that table. You can view the summary value of a table without expanding the nested table though the following workaround.

Solution:

The summary results of the nested tables can be obtained by using the GridEngine.GetSummaryText() method. In the following code example, the values are populated in the parent level unbound columns by using the QueryValue event. A hashtable is used to store the values entered in the unbound column as it does not have its own datastore.

C#

//Hooks QueryValue event to set the UnboundCol value.
this.gridGroupingControl1.QueryValue += gridGroupingControl1_QueryValue;
private void gridGroupingControl1_QueryValue(object sender, Syncfusion.Grouping.FieldValueEventArgs e)
{
   if (e.TableDescriptor.Name == this.parentTD.Name)
   {
      Group g = e.Record.NestedTables[0].ChildTable as Group;
      e.Value = GridEngine.GetSummaryText(g, "r_sum", "c_sum");
   }
   else if (e.TableDescriptor == this.childTD)
   {
      Group g = e.Record.NestedTables[0].ChildTable as Group;
      e.Value = GridEngine.GetSummaryText(g, "gc_ROW", "gc_SUM");
   }
   else if (e.TableDescriptor == this.grandChildTD)
   {
      object o = this.unboundValues[e.Record.GetValue("GrandChildID").ToString()];
      double d;
      if (o != null && double.TryParse(o.ToString(), System.Globalization.NumberStyles.Any, null, out d))
      {
         e.Value = d;
      }
   }
}

VB

'Hooks the QueryValue event to set the UnboundCol value.
Me.gridGroupingControl1.QueryValue += gridGroupingControl1_QueryValue
Private Sub gridGroupingControl1_QueryValue(ByVal sender As Object, ByVal e As Syncfusion.Grouping.FieldValueEventArgs)
   If e.TableDescriptor.Name = Me.parentTD.Name Then
      Dim g As Group = TryCast(e.Record.NestedTables(0).ChildTable, Group)
      e.Value = GridEngine.GetSummaryText(g, "r_sum", "c_sum")
   ElseIf e.TableDescriptor = Me.childTD Then
      Dim g As Group = TryCast(e.Record.NestedTables(0).ChildTable, Group)
      e.Value = GridEngine.GetSummaryText(g, "gc_ROW", "gc_SUM")
   ElseIf e.TableDescriptor = Me.grandChildTD Then
      Dim o As Object = Me.unboundValues(e.Record.GetValue("GrandChildID").ToString())
      Dim d As Double
      If o IsNot Nothing AndAlso Double.TryParse(o.ToString(), System.Globalization.NumberStyles.Any, Nothing, d) Then
         e.Value = d
      End If
   End If
End Sub

The following screenshot displays the summary results:

Show the summary results in parent level

Figure 1: Summary Results in Parent Level

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied