Learn how to get the Filtered data from the DevExpress Datagrid?
Here, we are reading the data from database in the function GetDataFromDatabase() and storing it in the dataset, ds. Then we are displaying it on to the datagrid. (This code may be written in the Read button.)
Dim ds As New DataSet
Dim dv As DataView
ds = GetDataFromDatabase()
Dim dvManager As New DataViewManager(ds)
dv = dvManager.CreateDataView(ds.Tables(0))
GridControl1.DataSource = dv
We are copying the data in datagrid on to another table, dtRecords. (whole data read from the database will be there.)
If ActiveFilterCriteria is present, then the filtered contents is copied to dtRecords.
Dim dtRecords As DataTable = dv.ToTable
If Not (IsNothing(GridView1.ActiveFilterCriteria)) Then
Dim filteredDataView As New DataView(dtRecords)
filteredDataView.RowFilter = DevExpress.Data.Filtering.CriteriaToWhereClauseHelper.GetDataSetWhere(GridView1.ActiveFilterCriteria)
dtRecords = filteredDataView.ToTable
We could set the AutoFilterRow as True by clicking 'Run Designer' in GridControl1 -> 'Feature Browser' on the left hand side -> 'Filtering' -> In its Properties 'OptionsView' -> set 'ShowAutoFilterRow' as True