How to inherit the scrolling from parent widget to Flutter DataGrid?
In this article, we will show you how to inherit the scrolling from parent widget to Flutter DataTable.
Initialize the SfDataGrid widget with all the necessary properties. To do this, wrap SingleChildScrollView around SfDataGrid as its parent. Then, enable SfDataGrid.shrinkWrapRows to set the height of the datagrid based on the available number of rows. However, note that when using shrinkWrapRows, all rows are constructed during the initial loading to calculate the height of the DataGrid. This approach helps eliminate the inner scroll and enables scrolling through its parent SingleChildScrollView.
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Syncfusion Flutter DataGrid'),
),
body: SingleChildScrollView(
child: Column(
children: [
Container(
height: 200,
color: Colors.green,
child: const Center(
child: Text(
'Container widget 1',
style: TextStyle(
color: Colors.white,
fontSize: 20,
),
),
),
),
SfDataGrid(
shrinkWrapRows: true,
source: employeeDataSource,
columnWidthMode: ColumnWidthMode.fill,
columns: getColumns
),
],
),
),
);
}
You can download this example on GitHub.
Conclusion
I hope you enjoyed learning about how to inherit the scrolling from parent widget to Flutter DataGrid.
You can refer to our Flutter DataGrid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!