WPF DataGrid (SfDataGrid) Overview

14 Aug 20235 minutes to read

The SfDataGrid (DataGrid) control for WPF is used to display collection of data in rows and columns. The SfDataGrid control includes editing, exporting and data shaping features (sorting, grouping, filtering and etc) that allows the end users to easily manage the data.

Following are the key features of SfDataGrid control

  • Data binding – Supports to bind different types of data sources.
  • Selection – Support for row and also cell selection.
  • Editing – Interactive support to edit with different column types.
  • Columns – Support for various column types including unbound columns.
  • Sorting – Interactive support to sort the data in SfDataGrid.
  • Grouping – Interactive support to group the data in SfDataGrid.
  • Summaries – Extensive support to show concise information about the individual data columns or groups of rows.
  • Filtering – Interactive support for filtering data as like in Excel.
  • Data validation – Support to validate the data on errors.
  • Data virtualization – Support for different modes of data virtualization such as paging, incremental loading.
  • Master-Detail View – Support to display relational data using hierarchies.
  • Printing and Exporting – Support to print and also export the data to Excel, PDF.
  • Styling – Extensive support for customizing styles of cells and rows in SfDataGrid.
  • Stacked Headers – Extensive support to show multiple headers called stacked headers.
  • Unbound rows – Support to display unbound rows.
  • Touch support – Complete support for resizing, drag-drop column, sorting, filtering, grouping and etc in touch devices.

Choose between different Grid’s

Syncfusion WPF suite comes up with following different Grid’s namely,

  1. GridControl
  2. GridTreeControl and SfTreeGrid
  3. GridDataControl and SfDataGrid

GridControl

GridControl is designed based on the cell-oriented architecture that does not make any assumptions about the structure of the data and provides support for Excel-like features. This control can be used when the data is populated in on demand using virtualization or its internal storage. It is not possible to bind the data source directly.

GridTreeControl and SfTreeGrid

The GridTreeControl and SfTreeGrid control is a data-oriented control that displays self-relational data in a tree structure user interface like multicolumn treeview. The data can be loaded on demand. You can move items between parent nodes by using the built-in row drag-and-drop functionality. Its rich feature set includes editing with different column types, selection, and node selection with check boxes, sorting, and filtering.

GridDataControl and SfDataGrid

The GridDataControl and SfDataGrid controls are used to display collection of data in rows and columns. These controls support the data binding directly.

  1. SfDataGrid - SfDataGrid is designed based on the WPF template-based architecture that provides support to customize the Grid easily and fully supports binding.
  2. GridDataControl - GridDataControl is designed based on the cell-oriented architecture of the Windows Forms Grid control that provides more control over cells and supports for Excel-like features.

Both SfDataGrid and GridDataControl almost have the same set of features. But SfDataGrid control offers rich set of features over GridDataControl. When you want cell level customization and excel-like features you can use GridDataControl. When you want performance, customization features like styles & template features specific to WPF, you can use SfDataGrid control. Comparatively, the performance of SfDataGrid control is better than the GridDataControl.

NOTE

GridDataControl is marked as classic control. In future, new features & enhancements will be added only in SfDataGrid. It recommended to use SfDataGrid.

You can see the list of some of the specific API difference between GridDataControl and SfDataGrid as follows:

GridDataControl SfDataGrid Description
AutoPopulateColumns AutoGenerateColumns To Generate the Columns
AllowEdit AllowEditing To Edit the GridCells
AllowGroup AllowGrouping To Group the Column header
AllowResizeColumns AllowResizingColumns To Resize the columns
AllowDragColumns AllowDraggingColumns To Drag the columns
AllowSort AllowSorting To Sort the columns
ShowFilters AllowFiltering To Show the Filters in a Grid
VisibleColumn Column To Specify the GridColumns
AllowExcelLikeResizing AllowResizingHiddenColumns To Allow Resizing on the Hidden Columns
ShowHoveringBackground AllowRowHoverHighlighting To show the Hovers for Highlighting rows.
EnableTriStateSorting AllowTristateSorting To allow Tri State Sorting
ExpandGroupsWhenGrouped AutoExpandGroups To Allow Auto Expand groups
AutoPopulateRelations AutoGenerateRelations To set an item source for child Grid.
SortColumns SortColumnDescriptions The column sorting based on the column descriptions that are given in a particular column.
ShowSortNumber ShowSortNumbers To Show the Sorted Numbers when sorting.
HideColumnsWhenGrouped ShowColumnsWhenGrouped To Show the Columns when grouped.
HighlightSelectionBackground RowSelectionBrush To give a color for RowSelection.
ListBoxSelectionMode SelectionMode To Specify the Selection Mode for a selection.
DefaultHeaderRowHight HeaderRowHeight Specifies the Header Row and Height.
SummaryRows GroupSummaryRows To Group the Summary row based on the Summary given in that row.
FrozenRows FrozenRowsCount The number of rows is freeze from Top.
FooterRows FooterRowsCount The number of rows is freeze from bottom.
FrozenColumns FrozenColumnCount The number of columns is freeze from left.
FooterColumns FooterColumnCount The number of columns is freeze from right.

You can see the list of rich set of features in SfDataGrid over GridDataControl as follows:

Rich set of features in SfDataGrid over GridDataControl.

Feature Description
AutoRowHeight SfDataGrid enables fitting the height of the row based on its content on demand for all columns or certain columns by using

AutoRowHeight

.
CellTemplate Support for all columns SfDataGrid provides support for

CellTemplate

. It is used to customize columns in display mode that present cells with DataTemplate.
IEditableObjectSupport SfDataGrid supports to roll back the changes when you press Esc Key by implementing IEditableObject interface. For more information about IEditableObject refer

IEditableObject

.
Incremental Loading

IncrementalLoading

allows you to load a subset of data to  SfDataGrid sequentially. It provides support for fast and fluid scrolling and loading a huge set of data.
Printing The Printing feature in SfDataGrid is more flexible and customizable. It also provides a good performance when compared to GridDataControl.For more information about CustomPrinting, click

here

.The PrintManager of SfDataGrid is designed to support different orientations, sizes, margins etc.
Exporting To Excel SfDataGrid control provides support to Export data to Excel and returns an ExcelEngine that contains the exported workbook. SfDataGrid Exporting is faster than GridDataControl. It exports the content only to the excel sheet. It takes very less time to export the huge amounts of data. To know more about exporting in SfDataGrid, click

here

.
Exporting To PDF SfDataGrid control provides support for exporting the data into a PDF file. You can decide what are the contents is need to export in PDF file. You can export Grouping, Filtering, Summaries and DetailsView, StackedHeaders in to PDF file.To get more information about

ExportToPdf

.
FilterPopupPerformance When you have a large amount of data, it takes time to load the Filter popup. Though, you are having lots of data, you can get better performance while loading Filter popup, by setting CanGenerateUniqueItems to False. To know more about FilterPopupPerformance, click

here

.
DataVirtualization

DataVirtualization

is a term that achieves Virtualization for the actual data objects that are bound to the DataGrid. For small collection of basic data objects, the memory consumption is not significant. However for large collections, the memory consumption becomes very significant.