Open
Description
Bug description
Hello!
When tapping the filter icon, the column is sometimes (not always) sorted instead of opening the filter popup. I have provided a video capture that demonstrates the issue.
As you can see, when the filter icon is tapped, the column's sorting is sometimes changed instead of opening the filter popup. Furthermore, when I tap a 2nd time without moving my cursor, the filter popup opens normally as intended.
Sadly, I wasn't able to reproduce the issue in any of your examples. I have provided the code that customizes the filter and sort icons in my grid. Let me know if you need anything else!
Thanks!
Mathieu
Steps to reproduce
- Tap the filter icon
- Sometimes, the column is sorted rather than the filter's popup menu opened
Code sample
Code sample
SfDataGridThemeData(
headerColor: Theme.of(context).colorScheme.surfaceContainerHighest,
selectionColor: Theme.of(context).colorScheme.primaryContainer,
gridLineStrokeWidth: 0,
sortIcon: Builder(
builder: (context) {
// Modifie l'icône de tri en fonction du tri appliqué sur la
// colonne. L'icône tient aussi compte de la densité visuelle.
//
// Basé sur https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfDataGridThemeData/sortIcon.html
String columnName = '';
context.visitAncestorElements((element) {
if (element is GridHeaderCellElement) {
columnName = element.column.columnName;
}
return true;
});
final column = _gridSource.sortedColumns
.where((element) => element.name == columnName)
.firstOrNull;
final isSortedColumn = column != null;
late IconData iconData;
switch (column?.sortDirection) {
case DataGridSortDirection.ascending:
iconData = Icons.arrow_upward;
break;
case DataGridSortDirection.descending:
iconData = Icons.arrow_downward;
break;
default:
iconData = Icons.swap_vert;
}
return Icon(
iconData,
size: 25.0 + widget.verticalVisualDensity * 1.5,
color: isSortedColumn
? dirtyColor
: Theme.of(context).colorScheme.outline,
);
},
),
filterIcon: Builder(
builder: (context) {
// Affiche un badge sur l'icône de filtre de la colonne si celle-ci
// est filtrée. L'icône tient aussi compte de la densité visuelle.
//
// Basé sur https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfDataGridThemeData/filterIcon.html
String columnName = '';
context.visitAncestorElements((element) {
if (element is GridHeaderCellElement) {
columnName = element.column.columnName;
}
return true;
});
final isFilteredColumn =
_gridSource.filterConditions.containsKey(columnName);
return Icon(
Icons.filter_alt_outlined,
size: 25.0 + widget.verticalVisualDensity * 1.5,
color: isFilteredColumn
? dirtyColor
: Theme.of(context).colorScheme.outline,
);
},
),
)
Screenshots or Video
Stack Traces
No stack trace.
On which target platforms have you observed this bug?
Windows
Flutter Doctor output
Doctor output
Using syncfusion_flutter_datagrid: ^28.1.33
[✓] Flutter (Channel stable, 3.24.4, on Microsoft Windows [Version 10.0.19045.5247], locale en-CA)
[✓] Windows Version (Installed version of Windows is version 10 or higher)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Chrome - develop for the web
[✓] Visual Studio - develop Windows apps (Visual Studio Professional 2022 17.12.3)
[!] Android Studio (version 2022.1)
✗ Unable to determine bundled Java version.
[✓] Android Studio (version 2023.3)
[✓] VS Code, 64-bit edition (version 1.96.0)
[✓] Connected device (3 available)
[✓] Network resources