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/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/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([]); + } +} 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, ),