From aec6708e328b1ef69e0b6066dd771a6704114f45 Mon Sep 17 00:00:00 2001 From: spe Date: Sat, 7 Dec 2024 17:52:04 +0100 Subject: [PATCH 1/2] Added clear columns filter event --- demo/lib/main.dart | 1 + ...pluto_grid_clear_columns_filter_event.dart | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 lib/src/manager/event/pluto_grid_clear_columns_filter_event.dart diff --git a/demo/lib/main.dart b/demo/lib/main.dart index 7508fe92..82070b82 100644 --- a/demo/lib/main.dart +++ b/demo/lib/main.dart @@ -53,6 +53,7 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( + debugShowCheckedModeBanner: false, initialRoute: kReleaseMode ? HomeScreen.routeName : DevelopmentScreen.routeName, routes: { diff --git a/lib/src/manager/event/pluto_grid_clear_columns_filter_event.dart b/lib/src/manager/event/pluto_grid_clear_columns_filter_event.dart new file mode 100644 index 00000000..c873b7e9 --- /dev/null +++ b/lib/src/manager/event/pluto_grid_clear_columns_filter_event.dart @@ -0,0 +1,24 @@ +import 'package:pluto_grid_plus/pluto_grid_plus.dart'; + +/// Event to clear the provided columns there filter +class PlutoGridClearColumnsFilterEvent extends PlutoGridEvent { + final Iterable? columns; + final int? debounceMilliseconds; + final PlutoGridEventType? eventType; + + PlutoGridClearColumnsFilterEvent({ + this.columns, + this.debounceMilliseconds, + this.eventType, + }) : super( + type: eventType ?? PlutoGridEventType.normal, + duration: Duration( + milliseconds: debounceMilliseconds?.abs() ?? + PlutoGridSettings.debounceMillisecondsForColumnFilter), + ); + + @override + void handler(PlutoGridStateManager stateManager) { + stateManager.setFilterWithFilterRows([]); + } +} From 0191c585740d0492a1ce693cc3989c6283e7145c Mon Sep 17 00:00:00 2001 From: spe Date: Sat, 7 Dec 2024 17:53:05 +0100 Subject: [PATCH 2/2] FIX for https://github.com/doonfrs/pluto_grid_plus/issues/105 --- lib/pluto_grid_plus.dart | 1 + .../event/pluto_grid_change_column_filter_event.dart | 12 +++++------- lib/src/ui/columns/pluto_column_filter.dart | 1 + 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/pluto_grid_plus.dart b/lib/pluto_grid_plus.dart index 04ed11a9..daa732cd 100644 --- a/lib/pluto_grid_plus.dart +++ b/lib/pluto_grid_plus.dart @@ -17,6 +17,7 @@ export './src/manager/event/pluto_grid_cannot_move_current_cell_event.dart'; export './src/manager/event/pluto_grid_cell_gesture_event.dart'; export './src/manager/event/pluto_grid_change_column_filter_event.dart'; export './src/manager/event/pluto_grid_change_column_sort_event.dart'; +export './src/manager/event/pluto_grid_clear_columns_filter_event.dart'; export './src/manager/event/pluto_grid_drag_rows_event.dart'; export './src/manager/event/pluto_grid_event.dart'; export './src/manager/event/pluto_grid_scroll_update_event.dart'; diff --git a/lib/src/manager/event/pluto_grid_change_column_filter_event.dart b/lib/src/manager/event/pluto_grid_change_column_filter_event.dart index bc4623d5..432f92b0 100644 --- a/lib/src/manager/event/pluto_grid_change_column_filter_event.dart +++ b/lib/src/manager/event/pluto_grid_change_column_filter_event.dart @@ -7,21 +7,19 @@ class PlutoGridChangeColumnFilterEvent extends PlutoGridEvent { final PlutoFilterType filterType; final String filterValue; final int? debounceMilliseconds; + final PlutoGridEventType? eventType; PlutoGridChangeColumnFilterEvent({ required this.column, required this.filterType, required this.filterValue, this.debounceMilliseconds, + this.eventType, }) : super( - type: PlutoGridEventType.debounce, + type: eventType ?? PlutoGridEventType.normal, duration: Duration( - milliseconds: debounceMilliseconds == null - ? PlutoGridSettings.debounceMillisecondsForColumnFilter - : debounceMilliseconds < 0 - ? 0 - : debounceMilliseconds, - ), + milliseconds: debounceMilliseconds?.abs() ?? + PlutoGridSettings.debounceMillisecondsForColumnFilter), ); List _getFilterRows(PlutoGridStateManager? stateManager) { diff --git a/lib/src/ui/columns/pluto_column_filter.dart b/lib/src/ui/columns/pluto_column_filter.dart index 19e5b22a..e669d515 100644 --- a/lib/src/ui/columns/pluto_column_filter.dart +++ b/lib/src/ui/columns/pluto_column_filter.dart @@ -227,6 +227,7 @@ class PlutoColumnFilterState extends PlutoStateWithChange { column: widget.column, filterType: widget.column.defaultFilter, filterValue: changed, + eventType: PlutoGridEventType.debounce, debounceMilliseconds: stateManager.configuration.columnFilter.debounceMilliseconds, ),