Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (141).NET Core  (21)Angular  (36)ASP.NET  (47)ASP.NET Core  (52)ASP.NET MVC  (84)Azure  (26)Blazor  (42)DocIO  (18)Essential JS 2  (63)Essential Studio  (158)Flutter  (36)JavaScript  (131)Microsoft  (95)PDF  (46)React  (28)Succinctly series  (118)Syncfusion  (366)TypeScript  (30)Uno Platform  (2)UWP  (4)Vue  (24)Webinar  (11)Windows Forms  (51)WPF  (84)Xamarin  (98)XlsIO  (19)Other CategoriesBarcode  (4)BI  (29)Bold BI  (3)Build conference  (6)Business intelligence  (53)Button  (4)C#  (96)Chart  (36)Cloud  (8)Company  (446)Dashboard  (4)Data Science  (3)Data Validation  (2)DataGrid  (24)Development  (232)Doc  (7)eBook  (89)Enterprise  (22)Entity Framework  (4)Essential Tools  (14)Excel  (10)Extensions  (6)File Manager  (3)Gantt  (6)Gauge  (3)Git  (3)Grid  (24)HTML  (8)Installer  (1)Knockout  (2)LINQPad  (1)Linux  (1)M-Commerce  (1)Metro Studio  (11)Mobile  (121)Mobile MVC  (9)OLAP server  (1)Orubase  (12)Partners  (20)PDF viewer  (14)PHP  (1)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (4)Road Map  (9)Scheduler  (12)SfDataGrid  (7)Silverlight  (21)Sneak Peek  (7)Solution Services  (2)Spreadsheet  (2)SQL  (3)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (8)Tips and Tricks  (10)UI  (50)Uncategorized  (69)Unix  (2)User interface  (37)Visual State Manager  (1)Visual Studio  (12)Visual Studio Code  (6)Web  (76)What's new  (44)Windows 8  (19)Windows App  (1)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Share on twitter
Share on facebook
Share on linkedin

Grouping with WPF GridDataControl

With the Vol. 3 release, the much awaited grouping and summaries support for the WPF grid will be out. This support works with the CollectionView grouping mode. The summaries are not a part of CollectionView grouping logic, so we included high-level functions that will calculate the summaries of a group dynamically using LINQ methods. This only has the constraint of using IEnumerable<T> implemented data sources.


Interactive grouping

image

Considering you have the GridDataControl added in the XAML markup, just adding the following code snippet would let you define grouped columns.

 

<syncfusion:GridDataControl.GroupedColumns>
    <syncfusion:GridDataGroupColumn ColumnName="ShipCountry"/>
</syncfusion:GridDataControl.GroupedColumns>

 

Defining Summaries

There are three different types of summaries present in GDC:

  • Table Summary
  • Group Summary
  • Group Caption Summary

All of these have the same syntax to declare. You also have the option of seeing what kind of summary the end-user would prefer.

image

 

XAML code snippet:

Table Summary

<syncfusion:GridDataControl.TableSummaryRows>
    <syncfusion:GridDataSummaryRow ShowSummaryInRow=”True” Title=”Total Freight: {FreightSummary} For {CountSummary} Items” TitleColumnCount=”2″>
        <syncfusion:GridDataSummaryRow.SummaryColumns>
            <syncfusion:GridDataSummaryColumn Name=”FreightSummary” MappingName=”Freight” SummaryType=”Int32Aggregate” Format=”‘{Sum:c}'” />
            <syncfusion:GridDataSummaryColumn Name=”CountSummary” MappingName=”OrderDate” SummaryType=”CountAggregate” Format=”‘{Count:d}'” />
        </syncfusion:GridDataSummaryRow.SummaryColumns>
    </syncfusion:GridDataSummaryRow>
</syncfusion:GridDataControl.TableSummaryRows>

Group Summary

<syncfusion:GridDataControl.SummaryRows>
    <syncfusion:GridDataSummaryRow ShowSummaryInRow=”True” Title=”‘Charges – {FreightSummary} for {OrderCount} Items'”>
        <syncfusion:GridDataSummaryRow.SummaryColumns>
            <syncfusion:GridDataSummaryColumn Name=”FreightSummary”  MappingName=”Freight” SummaryType=”Int32Aggregate” Format=”‘{Sum:c}'” />
            <syncfusion:GridDataSummaryColumn Name=”OrderCount” MappingName=”OrderDate” SummaryType=”CountAggregate” Format=”‘{Count}'” />
        </syncfusion:GridDataSummaryRow.SummaryColumns>
    </syncfusion:GridDataSummaryRow>
</syncfusion:GridDataControl.SummaryRows>

Group Caption Summary

<syncfusion:GridDataControl.CaptionSummaryRow>
    <syncfusion:GridDataSummaryRow ShowSummaryInRow=”False” Title=”‘{Count} Items'” TitleColumnCount=”2″>
        <syncfusion:GridDataSummaryRow.SummaryColumns>
            <syncfusion:GridDataSummaryColumn Name=”FreightSummary”  MappingName=”Freight” SummaryType=”Int32Aggregate” Format=”‘{Sum:##}'” > 
            </syncfusion:GridDataSummaryColumn>
        </syncfusion:GridDataSummaryRow.SummaryColumns>
    </syncfusion:GridDataSummaryRow>
</syncfusion:GridDataControl.CaptionSummaryRow>

You may notice that each GridDataSummaryColumn has a Format property. This property specifies the value of the Summary and replaces it with a string that gets formatted. The below values are present for different summary types,

CountAggregate

  • Count

DoubleAggregate/Int32Aggregate

  • Count
  • Max
  • Min
  • Sum
  • Average

We can also add custom summaries and plug into the grid, but that needs a separate post to explain the workflow.

Tags:

Share this post:

Share on twitter
Share on facebook
Share on linkedin

Leave a comment

Popular Now

Be the first to get updates

Subscribe RSS feed
Scroll To Top