Fresh WPF Elements 5 Features – DataGrid Grouping and Exporting!

One of the great things about having a fast release cycle is being able to deliver cool new functionality as soon as it’s ready – no waiting for the next quarterly release for a crucial feature that could be released today. In the buildup to WPF Elements 5.1 we’ve been developing some great additions to the existing controls in the suite, as well as going through the codebase with a fine-toothed comb to ensure it remains highly stable and bug-free. We’re not cruel enough to make you wait for these improvements, so you can grab them from the nightly builds right now – both feature additions and bugfixes!

There are many small improvements to the API, such as being able to scroll a particular DataGrid cell into view, as well as two significant additions to the DataGrid we’re sure you’ll find very handy – Grouping and Exporting support. For the rest of the post I’ll be discussing how you can use these two features. First up – grouping!

Grouping

Users can now group data by any number of columns through an intuitive drag-and-drop interface – just drag a column header onto the grouping panel above the grid. Groups can be expanded and collapsed as expected, and the column grouping can be be removed by clicking on a button that appears on mouseover. Any number of columns can be added to the panel and the DataGrid will group the data in a nested fashion. Check out the demo below:

DataGrid animated grouping demo

Just set the IsGroupingPanelVisible property to True to enable the grouping UI. Alternatively, if you want to provide your own UI for grouping — or no UI at all, for example if you have an application where the data should always appear grouped — you can group on columns programatically by adding them to the GroupedColumns collection:

MyDataGrid.GroupedColumns.Add(MyDataGrid.EffectiveColumns[0]);

Easy as that. Our DataGrid performance is speedy even with millions of rows, and it stays that way even if the DataGrid has a complex nesting hierarchy.

Exporting

Another handy new feature is the ability to export the data in a DataGrid into an appropriate file format. At the moment we support the near-universal CSV format with more to come, and you can export to file, string or TextWriter. Again, it’s dead easy to use.

DataGridExporter.Csv.WriteFile(MyDataGrid, file);

In combination with a SaveFileDialog, you can export your DataGrid:

DataGrid exporting

and have the resulting file be opened by Excel, complete with columns automatically generated by the DataGrid from your collections.

That saves time! These two features along with bugfixes are available in the nightly builds right now, but they’ll officially be available in the WPF Elements 5.1 soon. You can check out the 60 day trial of WPF Elements 5 here featuring the DataGrid control plus more than 50 others.

Tagged as WPF Elements

2 Responses to “Fresh WPF Elements 5 Features – DataGrid Grouping and Exporting!”

Archives

Join our mailer

You should join our newsletter! Sent monthly:

Back to Top