You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Flutter/datagrid/filtering.md
+20-16Lines changed: 20 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,17 +9,17 @@ documentation: ug
9
9
10
10
# Filtering in Flutter DataGrid (SfDataGrid)
11
11
12
-
Filtering is the process of fetching the values from a collection that satisfies a specified condition. In the `SfDataGrid`, filtering can be applied through the UI and programmatically.
12
+
Filtering is the process of fetching the values from a collection that satisfies a specified condition. In the [SfDataGrid](https://pub.dev/documentation/syncfusion_flutter_datagrid/latest/datagrid/SfDataGrid-class.html), filtering can be applied through the UI and programmatically.
13
13
14
14
## Programmatical Filtering
15
15
16
-
The SfDataGrid allows you to filter the data rows programmatically by adding the filter conditions along with the respective column name to the `DataGridSource.filterConditions` map collection. In the map collection, the `key` defines the `columnName` and the `values` defines the list of `FilterCondition`.
16
+
The SfDataGrid allows you to filter the data rows programmatically by adding the filter conditions along with the respective column name to the [DataGridSource.filterConditions](https://pub.dev/documentation/syncfusion_flutter_datagrid/latest/datagrid/DataGridSource/filterConditions.html) map collection. In the map collection, the `key` defines the [columnName](https://pub.dev/documentation/syncfusion_flutter_datagrid/latest/datagrid/GridColumn/columnName.html) and the `values` defines the list of [FilterCondition](https://pub.dev/documentation/syncfusion_flutter_datagrid/latest/datagrid/FilterCondition-class.html).
17
17
18
18
`DataGridSource.filterConditions` is an unmodifiable map collection. So, it doesn't allow us to perform CRUD operations directly in the `DataGridSource.filterConditions` property. However, it can be done by the following public methods:
19
19
20
20
### Add filter
21
21
22
-
A filter condition to the specific column can be added by the `DataGridSource.addFilter` method.
22
+
A filter condition to the specific column can be added by the [DataGridSource.addFilter](https://pub.dev/documentation/syncfusion_flutter_datagrid/latest/datagrid/DataGridSource/addFilter.html) method.
A filter condition to the specific column can be removed by the `DataGridSource.removeFilter` method.
86
+
A filter condition to the specific column can be removed by the [DataGridSource.removeFilter](https://pub.dev/documentation/syncfusion_flutter_datagrid/latest/datagrid/DataGridSource/removeFilter.html) method.
The filter conditions from the entire column can be cleared by the `DataGridSource.clearFilters` method. The filter conditions in the specific column can also be cleared by invoking the `DataGridSource.clearFilters` method along with the corresponding `columnName` as an argument.
157
+
The filter conditions from the entire column can be cleared by the [DataGridSource.clearFilters](https://pub.dev/documentation/syncfusion_flutter_datagrid/latest/datagrid/DataGridSource/clearFilters.html) method. The filter conditions in the specific column can also be cleared by invoking the `DataGridSource.clearFilters` method along with the corresponding `columnName` as an argument.
The `FilterBehavior` property is used to specify whether filtering should consider the value of a cell as the string or its data type
220
+
The [FilterBehavior](https://pub.dev/documentation/syncfusion_flutter_datagrid/latest/datagrid/FilterBehavior.html) property is used to specify whether filtering should consider the value of a cell as the string or its data type
221
221
222
222
* **stringDataType** - It converts the cell value as string data type and compares the condition.
223
223
* **strongDataType** - It compares the cell value with its actual data type.
The `FilterOperator` property is used to decide how a logical operator is to be applied between multiple filter conditions.
293
+
The [FilterOperator](https://pub.dev/documentation/syncfusion_flutter_datagrid/latest/datagrid/FilterOperator.html) property is used to decide how a logical operator is to be applied between multiple filter conditions.
The column which holds the `DateTime` type data can be filtered with a range between two dates by applying the two filter conditions to the same column. The `FilterType` for the filter condition with the start date should be `GreaterThanOrEqual` and the end date should be `LessThanOrEqual` and the `FilterOperator` for the filter condition should be `and`.
375
+
The column which holds the [DateTime](https://api.flutter.dev/flutter/dart-core/DateTime-class.html) type data can be filtered with a range between two dates by applying the two filter conditions to the same column. The [FilterType](https://pub.dev/documentation/syncfusion_flutter_datagrid/latest/datagrid/FilterType.html) for the filter condition with the start date should be `GreaterThanOrEqual` and the end date should be `LessThanOrEqual` and the `FilterOperator` for the filter condition should be `and`.
376
376
377
377
{% tabs %}
378
378
{% highlight Dart %}
@@ -455,7 +455,7 @@ After filtering, the rows can be retrieved in the same order as displayed in the
455
455
456
456
## UI Filtering
457
457
458
-
The `SfDataGrid` provides an excel-like filtering UI and an advanced filter UI to filter the data easily. UI filtering can be enabled by setting the `SfDataGrid.allowFiltering` property to `true`. This allows the filter UI to be opened by clicking on the filter icon in the column header. The filtering UI will be shown as a popup menu on the desktop and web platforms, and it will be shown as a new page on the mobile platforms.
458
+
The `SfDataGrid` provides an excel-like filtering UI and an advanced filter UI to filter the data easily. UI filtering can be enabled by setting the [SfDataGrid.allowFiltering](https://pub.dev/documentation/syncfusion_flutter_datagrid/latest/datagrid/SfDataGrid/allowFiltering.html) property to `true`. This allows the filter UI to be opened by clicking on the filter icon in the column header. The filtering UI will be shown as a popup menu on the desktop and web platforms, and it will be shown as a new page on the mobile platforms.
459
459
460
460
The `SfDataGrid` provides the following types of filter popup modes:
461
461
@@ -472,8 +472,12 @@ The following image shows the advanced filter popup menu on the web and desktop
472
472
473
473
The following images show the checkbox and advanced filter popup menu on the mobile platform,
474
474
475
-
|  |  |
476
-
|:---:|:---:|
475
+
<table>
476
+
<tr>
477
+
<th><img alt="Flutter datagrid shows a checkbox filter menu on mobile platform" src="images/filtering/flutter-datagrid-checkbox-filter-view-mobile.png"/></td>
478
+
<th><img alt="Flutter datagrid shows a advanced filter menu on mobile platform" src="images/filtering/flutter-datagrid-advanced-filter-view-mobile.png"/></td>
479
+
</tr>
480
+
</table>
477
481
478
482
### Checkbox filtering
479
483
@@ -494,7 +498,7 @@ Below are the built-in filter types supported:
494
498
495
499
* **Text Filters** – Loads various menu options to filter the display text effectively.
496
500
* **Number Filters** – Loads various menu options to filter the numeric data.
497
-
* **Date Filters** – Loads various menu options and `DatePicker` to filter DateTime type column.
501
+
* **Date Filters** – Loads various menu options and [DatePicker](https://api.flutter.dev/flutter/material/showDatePicker.html) to filter DateTime type column.
498
502
499
503
<table>
500
504
<tr>
@@ -517,7 +521,7 @@ Below are the built-in filter types supported:
517
521
<td align="left" valign="top"><b>Filter menu options</b> <ul><li>Equals</li> <li>Does Not Equal</li> <li>Less Than</li> <li>Less Than Or Equal</li> <li>Greater Than</li> <li>Greater Than Or Equal</li> <li>Null</li> <li>Not Null</li></ul> </td>
518
522
<td align="left" valign="top"><b>Filter menu options</b> <ul><li>Equals</li> <li>Does Not Equal</li> <li>Before</li> <li>Before Or Equal</li> <li>After</li> <li>After Or Equal</li> <li>Null</li> <li>Not Null</li></ul> </td>
519
523
</tr>
520
-
<table>
524
+
</table>
521
525
522
526
The following image shows the advanced filter popup menu with multiple filter values and types in order to filter the range of data rows,
523
527
@@ -537,7 +541,7 @@ The following image shows the advanced filter popup menu with a case-sensitive i
537
541
538
542
### Disable filtering for an individual column
539
543
540
-
The `GridColumn.allowFiltering` has a higher priority than the `SfDataGrid.allowFiltering` property. So, you can disable the filtering for any particular column by setting the `GridColumn.allowFiltering` property to `false`.
544
+
The [GridColumn.allowFiltering](https://pub.dev/documentation/syncfusion_flutter_datagrid/latest/datagrid/GridColumn/allowFiltering.html) has a higher priority than the `SfDataGrid.allowFiltering` property. So, you can disable the filtering for any particular column by setting the `GridColumn.allowFiltering` property to `false`.
541
545
542
546
{% tabs %}
543
547
{% highlight Dart %}
@@ -597,7 +601,7 @@ The SfDataGrid provides the following callbacks to notify the filtering stages:
597
601
598
602
### OnFilterChanging callback
599
603
600
-
`onFilterChanging`callback invokes when the filtering is being applied to the particular column through UI filtering. You can return `false` from this callback to restrict the column from being filtered.
604
+
[onFilterChanging](https://pub.dev/documentation/syncfusion_flutter_datagrid/latest/datagrid/SfDataGrid/onFilterChanging.html) callback invokes when the filtering is being applied to the particular column through UI filtering. You can return `false` from this callback to restrict the column from being filtered.
`onFilterChanged`callback invokes after the filtering is applied to the particular column through UI filtering. You can use this callback to get filter conditions.
665
+
[onFilterChanged](https://pub.dev/documentation/syncfusion_flutter_datagrid/latest/datagrid/SfDataGrid/onFilterChanged.html) callback invokes after the filtering is applied to the particular column through UI filtering. You can use this callback to get filter conditions.
0 commit comments