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
Expanding a group and then sorting or filtering causes all groups to either expand or collapse based on the autoExpandGroups property, instead of preserving their current expanded/collapsed state.
Steps to reproduce
group a column
expand a group
sort or filter a column
Code sample
Code sample
import'package:flutter/material.dart';
import'package:syncfusion_flutter_datagrid/datagrid.dart';
voidmain() {
runApp(MyApp());
}
/// The application that contains datagrid on it.classMyAppextendsStatelessWidget {
@overrideWidgetbuild(BuildContext context) {
returnMaterialApp(
title:'Syncfusion DataGrid Demo',
theme:ThemeData(useMaterial3:false),
home:MyHomePage(),
);
}
}
/// The home page of the application which hosts the datagrid.classMyHomePageextendsStatefulWidget {
/// Creates the home page.MyHomePage({Key? key}) :super(key: key);
@override_MyHomePageStatecreateState() =>_MyHomePageState();
}
class_MyHomePageStateextendsState<MyHomePage> {
List<Employee> employees =<Employee>[];
lateEmployeeDataSource employeeDataSource;
@overridevoidinitState() {
super.initState();
employees =getEmployeeData();
employeeDataSource =EmployeeDataSource(employeeData: employees);
employeeDataSource
.addColumnGroup(ColumnGroup(name:'id', sortGroupRows:true));
}
@overrideWidgetbuild(BuildContext context) {
returnScaffold(
appBar:AppBar(
title:constText('Syncfusion Flutter DataGrid'),
),
body:SfDataGrid(
key:ValueKey('grid'),
source: employeeDataSource,
columnWidthMode:ColumnWidthMode.fill,
allowSorting:true,
allowFiltering:true,
allowExpandCollapseGroup:true,
autoExpandGroups:false,
columns:<GridColumn>[
GridColumn(
columnName:'id',
label:Container(
padding:EdgeInsets.all(16.0),
alignment:Alignment.center,
child:Text(
'ID',
),
),
),
GridColumn(
columnName:'name',
label:Container(
padding:EdgeInsets.all(8.0),
alignment:Alignment.center,
child:Text('Name'),
),
),
GridColumn(
columnName:'designation',
label:Container(
padding:EdgeInsets.all(8.0),
alignment:Alignment.center,
child:Text(
'Designation',
overflow:TextOverflow.ellipsis,
))),
GridColumn(
columnName:'salary',
label:Container(
padding:EdgeInsets.all(8.0),
alignment:Alignment.center,
child:Text('Salary'))),
],
),
);
}
List<Employee> getEmployeeData() {
return [
Employee(10001, 'James', 'Project Lead', 20000),
Employee(10002, 'Kathryn', 'Manager', 30000),
Employee(10003, 'Lara', 'Developer', 15000),
Employee(10004, 'Michael', 'Designer', 15000),
Employee(10005, 'Martin', 'Developer', 15000),
Employee(10006, 'Newberry', 'Developer', 15000),
Employee(10007, 'Balnc', 'Developer', 15000),
Employee(10008, 'Perry', 'Developer', 15000),
Employee(10009, 'Gable', 'Developer', 15000),
Employee(10010, 'Grimes', 'Developer', 15000)
];
}
}
/// Custom business object class which contains properties to hold the detailed/// information about the employee which will be rendered in datagrid.classEmployee {
/// Creates the employee class with required details.Employee(this.id, this.name, this.designation, this.salary);
/// Id of an employee.finalint id;
/// Name of an employee.finalString name;
/// Designation of an employee.finalString designation;
/// Salary of an employee.finalint salary;
}
/// An object to set the employee collection data source to the datagrid. This/// is used to map the employee data to the datagrid widget.classEmployeeDataSourceextendsDataGridSource {
/// Creates the employee data source class with required details.EmployeeDataSource({requiredList<Employee> employeeData}) {
_employeeData = employeeData
.map<DataGridRow>((e) =>DataGridRow(cells: [
DataGridCell<int>(columnName:'id', value: e.id),
DataGridCell<String>(columnName:'name', value: e.name),
DataGridCell<String>(
columnName:'designation', value: e.designation),
DataGridCell<int>(columnName:'salary', value: e.salary),
]))
.toList();
}
List<DataGridRow> _employeeData = [];
@overrideList<DataGridRow> get rows => _employeeData;
@overrideWidget?buildGroupCaptionCellWidget(
RowColumnIndex rowColumnIndex, String summaryValue) {
returnAlign(
alignment:Alignment.centerLeft,
child:Text(summaryValue),
);
}
@overrideDataGridRowAdapterbuildRow(DataGridRow row) {
returnDataGridRowAdapter(
cells: row.getCells().map<Widget>((e) {
returnContainer(
alignment:Alignment.center,
padding:EdgeInsets.all(8.0),
child:Text(e.value.toString()),
);
}).toList());
}
}
Screenshots or Video
Screenshots / Video demonstrationgroups_sort_bug.mp4
Stack Traces
Stack Traces
NoStack trace
On which target platforms have you observed this bug?
Windows
Flutter Doctor output
Doctor output
[√] Flutter (Channel stable, 3.24.4, on Microsoft Windows [Version 10.0.26100.2605], locale en-CA) • Flutter version 3.24.4 on channel stable at C:\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 603104015d (3 months ago), 2024-10-24 08:01:25 -0700 • Engine revision db49896cf2 • Dart version 3.5.4 • DevTools version 2.37.3[√] Windows Version (Installed version of Windows is version 10 or higher)[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0) • Platform android-35, build-tools 35.0.0 • Java version OpenJDK Runtime Environment (build 17.0.10+0--11609105) • All Android licenses accepted.[√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe[√] Visual Studio - develop Windows apps (Visual Studio Professional 2022 17.10.4) • Visual Studio Professional 2022 version 17.10.35027.167 • Windows 10 SDK version 10.0.22621.0[√] Android Studio (version 2024.1) • Java version OpenJDK Runtime Environment (build 17.0.10+0--11609105)[√] IntelliJ IDEA Community Edition (version 2024.2) • Dart plugin version 242.21829.3[√] VS Code (version 1.96.2) • Flutter extension version 3.102.0[√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.26100.2605] • Chrome (web) • chrome • web-javascript • Google Chrome 131.0.6778.205 • Edge (web) • edge • web-javascript • Microsoft Edge 131.0.2903.99[√] Network resources • All expected network resources are available.• No issues found!
The text was updated successfully, but these errors were encountered:
In SfDataGrid, enabling grouping with the SfDataGrid.autoExpandGroups property causes the expand and collapse states of the groups to reset when performing CRUD operations. This behavior is expected. We have also included this as a limitation in our user guide documentation. Please refer to the below UG documentation for more information.
Since this is not a bug, I'd like to point out something in the video. After sorting, all groups collapse, but the groups that were previously open still have their arrow indicators pointing in the wrong direction. This issue is visible on ID: 10006 at the end of the video.
The reported issue is a known issue on our side. We are pleased to inform you that it has been resolved on our end. Therefore, kindly update SfDataGrid to the latest version(28.1.41).
Root cause : We used a StatefulWidget with rowIndex as the key for the widget. When the underlying data of the widget changes but the key remains the same, the widget's old state may persist incorrectly. Since the rowIndex remains unchanged during actions like sorting, the old state was being reflected.
If you have any further queries, please don't hesitate to reach out. We are more than happy to assist you.
We suspect that the reported issue has been resolved at your end. Hence, we are closing this issue. If you need any further assistance, please reopen this. We are always happy to help.
Bug description
Expanding a group and then sorting or filtering causes all groups to either expand or collapse based on the autoExpandGroups property, instead of preserving their current expanded/collapsed state.
Steps to reproduce
Code sample
Code sample
Screenshots or Video
Screenshots / Video demonstration
groups_sort_bug.mp4
Stack Traces
Stack Traces
On which target platforms have you observed this bug?
Windows
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: