Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (161).NET Core  (29).NET MAUI  (64)Angular  (74)ASP.NET  (50)ASP.NET Core  (79)ASP.NET MVC  (88)Azure  (36)Blazor  (153)DocIO  (23)Essential JS 2  (85)Essential Studio  (174)File Formats  (29)Flutter  (123)JavaScript  (187)Microsoft  (113)PDF  (67)React  (62)Succinctly series  (128)Syncfusion  (610)TypeScript  (31)Uno Platform  (3)UWP  (4)Vue  (39)Webinar  (35)Windows Forms  (59)WinUI  (52)WPF  (138)Xamarin  (155)XlsIO  (25)Other CategoriesBarcode  (5)BI  (29)Bold BI  (5)Build conference  (6)Business intelligence  (54)Button  (4)C#  (120)Chart  (57)Cloud  (12)Company  (445)Dashboard  (8)Data Science  (3)Data Validation  (6)DataGrid  (55)Development  (400)Doc  (7)DockingManager  (1)eBook  (96)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (23)Extensions  (18)File Manager  (4)Gantt  (11)Gauge  (11)Git  (4)Grid  (28)HTML  (11)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (312)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (30)Performance  (9)PHP  (1)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (7)Road Map  (10)Scheduler  (36)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (22)Solution Services  (3)Spreadsheet  (11)SQL  (8)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (11)Tips and Tricks  (92)UI  (224)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (23)Visual Studio Code  (17)Web  (375)What's new  (213)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Share on twitter
Share on facebook
Share on linkedin
Seamless Excel-Like Filtering Support in Flutter DataGrid

Seamless Excel-Like Filtering Support in Flutter DataGrid

Filtering is an essential feature in the DataGrid control. It lets us view the rows based on our required criteria. Excel-like filtering support provides users more flexibility to filter the rows as needed, easily. We are happy to announce that we have provided Excel-like filtering support to our Flutter DataGrid in the Essential Studio 2022 Volume 3 release.

In this blog, we will walk through filtering in columns using the new Excel-like filtering feature.

Getting started

You can enable excel-like filtering by just setting the SfDataGrid.allowFiltering property to true. By enabling this property, you can see the filter icons in the column header.

Flutter DataGrid widget with allowFiltering property enabled
Flutter DataGrid widget with allowFiltering property enabled

When clicking the filter icon, the Excel-like filtering pop-up will appear.

Flutter DataGrid with Excel-like filtering pop-up
Flutter DataGrid with Excel-like filtering pop-up

Filtering options

The Excel-like filtering pop-up depicts most of the options from Excel, being inspired by the Excel filter pop-up.

The filter pop-up consists of the following UI parts:

  • Sorting (both directions)—Easily sort the data in ascending or descending order.
  • Clear filter—Clear the filter applied to the column.
  • Advanced filter option.
  • Checkbox filtering.

Checkbox filtering

Checkbox filtering is a straightforward approach to searching for the required data from the available data in a column. You can choose the data through the checked ListBox in the filter pop-up. A blank item is added automatically if the column has null or empty data.

The following .gif image depicts how to apply the filtering using the checked ListBox option.

Table with Excel-like checkbox filtering
Table with Excel-like checkbox filtering

Advanced filter option

The advanced filter options are available based on the data type of the columns. The data types with the advanced filtering option are:

  • Text
  • Number
  • Date

The advanced filter option helps us to apply multiple filter conditions with the required filter criteria. Each type of filter has its own set of filter conditions to apply filtering with ease. The following table shows the list of filter conditions that are supported in advanced filter options.

TextNumberDate
  • Equals
  • Does Not Equal
  • Begins With
  • Does Not Begin With
  • Ends With
  • Does Not End With
  • Contains
  • Does Not Contain
  • Empty
  • Not Empty
  • Null
  • Not Null
  • Equals
  • Does Not Equal
  • Less Than
  • Less Than Or Equal
  • Greater Than
  • Greater Than Or Equal
  • Null
  • Not Null
  • Equals
  • Does Not Equal
  • After
  • After Or Equal
  • Before
  • Before Or Equal
  • Null
  • Not Null

You can also choose whether the AND or OR logical operator should be applied between the two filter conditions you applied in the advanced filter options.

The following GIF depicts how to apply multiple filter conditions to a column.

Flutter DataGrid with Excel-like filtering demo for advanced filter options
Flutter DataGrid with Excel-like filtering demo for advanced filter options

You can retrieve just the filtered rows using the DataGridSource.effectiveRows property.

Callbacks

The following callbacks are implemented to listen when filtering is applied through an Excel-like filter pop-up:

  • onFilterChanging—This is invoked when the filtering is being applied to a specific column.
  • onFilterChanged—This is invoked after the filtering is applied to the specific column.

Programmatic filtering

DataGrid also lets users apply filtering programmatically without using Excel-like UI filtering. This can be done 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 define the list of FilterCondition.

The following methods can be used to do the filtering programmatically:

The following example shows how to add a filter condition programmatically.

@override
Widget build(BuildContext context) {
  return Column(
    children: [
      Expanded(
        child: SfDataGrid(source: _employeeDataSource, columns: [
          GridColumn(
              columnName: 'ID',
              label: Container(
                  padding: EdgeInsets.symmetric(horizontal: 16.0),
                  alignment: Alignment.centerRight,
                  child: Text(
                    'ID',
                    overflow: TextOverflow.ellipsis,
                  ))),
          GridColumn(
              columnName: 'Name',
              label: Container(
                  padding: EdgeInsets.symmetric(horizontal: 16.0),
                  alignment: Alignment.centerLeft,
                  child: Text(
                    'Name',
                    overflow: TextOverflow.ellipsis,
                  ))),
          GridColumn(
              columnName: 'Designation',
              label: Container(
                  padding: EdgeInsets.symmetric(horizontal: 16.0),
                  alignment: Alignment.centerLeft,
                  child: Text(
                    'Designation',
                    overflow: TextOverflow.ellipsis,
                  ))),
          GridColumn(
              columnName: 'Salary',
              label: Container(
                  padding: EdgeInsets.symmetric(horizontal: 16.0),
                  alignment: Alignment.centerRight,
                  child: Text(
                    'Salary',
                    overflow: TextOverflow.ellipsis,
                  ))),
        ]),
      ),
      MaterialButton(
          child: Text('Add Filter'),
          onPressed: () {
            _employeeDataSource.addFilter('ID',
                FilterCondition(type: FilterType.lessThan, value: 1005));
          }),
    ],
  );
}

Resource

For more details, refer to the project Excel-like filtering in Flutter DataGrid.

Conclusion

I hope you found this blog interesting. You may browse Excel-like filtering in Flutter DataGrid UG for more information on filtering features and examples.

Existing customers can obtain the most recent version of Essential Studio by visiting the License and Downloads page. If you are not already a Syncfusion customer, you may sign up for a 30-day free trial to explore what features are available.

Also, you can contact us via our support forums, support portal, or feedback portal with any questions. We are always happy to help you!

Related blogs

Tags:

Share this post:

Share on twitter
Share on facebook
Share on linkedin
Popular Now

Be the first to get updates

Subscribe RSS feed
Scroll To Top