Skip to content

Commit 67f29ff

Browse files
ES-975464 - Addressed the concerns
1 parent c206c8c commit 67f29ff

File tree

5 files changed

+48
-3
lines changed

5 files changed

+48
-3
lines changed

DataGridWithDataTable.png

65.9 KB
Loading

DataGridWithFilteringApplied.png

23.5 KB
Loading

DataGridWithGroupingApplied.png

72.9 KB
Loading

DataGridWithSortingApplied.png

66 KB
Loading

README.md

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# How to bind the data table to WPF DataGrid
1+
# How to Bind the DataTable to WPF DataGrid?
22

33
This sample show cases how to bind the data table to [WPF DataGrid](https://www.syncfusion.com/wpf-ui-controls/datagrid) (SfDataGrid).
44

@@ -15,6 +15,7 @@ public class ViewModel
1515
{
1616
DataTableCollection = GetDataTable();
1717
}
18+
1819
public DataTable DataTableCollection { get; set; }
1920

2021
private DataTable GetDataTable()
@@ -51,7 +52,7 @@ public class ViewModel
5152

5253
### Binding ItemsSource in XAML
5354

54-
In the main page, add the necessary XML namespace to use `SfDataGrid` control, set the DataContext of the window to the `ViewModel` class, and bind the `ItemsSource` of `SfDataGrid` with the `DataTableCollection`.
55+
In the main page, add the necessary XML namespace to use `DataGrid` control, set the DataContext of the window to the `ViewModel` class, and bind the `ItemsSource` of `DataGrid` with the `DataTableCollection`.
5556

5657
``` xml
5758
<Window x:Class="SfDataGridDemo.MainWindow"
@@ -72,4 +73,48 @@ In the main page, add the necessary XML namespace to use `SfDataGrid` control, s
7273
</Window>
7374
```
7475

75-
![](https://www.syncfusion.com/uploads/user/kb/wpf/wpf-49287/wpf-49287_img1.png)
76+
![DataGrid loaded with DataTable Collection](DataGridWithDataTable.png)
77+
78+
79+
### CRUD operations
80+
81+
DataGrid automatically refreshes the UI whenever we add, delete or modify the rows of the underlying DataTable collection.
82+
83+
### Data operations
84+
85+
DataGrid supports various data operations to represent the data in it. The following are supported by default:
86+
87+
* Sorting (including multicolumn sorting)
88+
* Grouping (including multicolumn grouping)
89+
* Filtering
90+
* Summaries
91+
92+
#### Sorting
93+
94+
You can sort columns with the various built-in options such as [multicolumn sorting](https://help.syncfusion.com/wpf/datagrid/sorting#multi-column-sorting) and [tri-state sorting](https://help.syncfusion.com/wpf/datagrid/sorting#sorting-order). But [custom sorting](https://help.syncfusion.com/wpf/datagrid/sorting#custom-sorting) is not supported.
95+
96+
In the following screenshot, the datagrid is sorted in ascending order with respect to the **Customer Name** column.
97+
98+
![DataGrid with sorting applied to Customer Name column](DataGridWithSortingApplied.png)
99+
100+
#### Grouping
101+
102+
The data can be organized in a hierarchical structure based on matching field values. [Custom grouping](https://help.syncfusion.com/wpf/datagrid/grouping#custom-grouping) are also supported.
103+
104+
![DataGrid with grouping applied to country column](DataGridWithGroupingApplied.png)
105+
106+
#### Filtering
107+
108+
You can filter columns with the various built-in options such as [Excel like UI filtering](https://help.syncfusion.com/wpf/datagrid/filtering#excel-like-ui-filtering), [Advanced UI filtering](https://help.syncfusion.com/wpf/datagrid/filtering#advanced-filter-ui) and [Programmatic filtering](https://help.syncfusion.com/wpf/datagrid/filtering#column-filtering) by using [FilterPredicates](https://help.syncfusion.com/cr/cref_files/wpf/Syncfusion.SfGrid.WPF~Syncfusion.UI.Xaml.Grid.GridColumn~FilterPredicates.html). But DataGrid’s built-in [View.Filter](https://help.syncfusion.com/cr/wpf/Syncfusion.Data.CollectionViewAdv.html#Syncfusion_Data_CollectionViewAdv_Filter) is not supported for the DataTable class. But you can filter the records using DataTable's [DataView.RowFilter](https://docs.microsoft.com/en-us/dotnet/api/system.data.dataview.rowfilter?view=netframework-4.8) property.
109+
110+
![DataGrid with filtering applied to country column](DataGridWithFilteringApplied.png)
111+
112+
#### Summaries
113+
114+
All summary types supported by DataGrid are supported for DataTable, i.e. [group summary](https://help.syncfusion.com/wpf/datagrid/summaries#group-summary), [caption summary](https://help.syncfusion.com/wpf/datagrid/summaries#caption-summaries), and [table summary](https://help.syncfusion.com/wpf/datagrid/summaries#table-summary).
115+
116+
### Other features
117+
118+
The support for all other features, such as stacked headers, row drag and drop, unbound column, and unbound row, of DataGrid are available.
119+
120+
Take a moment to peruse the [WPF DataGrid - Overview](https://help.syncfusion.com/wpf/datagrid/overview) documentation, to learn more about the DataGrid's feature sets.

0 commit comments

Comments
 (0)