From 95d8838d592504827874ea828422de7d15f370c4 Mon Sep 17 00:00:00 2001 From: Abinesh Date: Mon, 15 Jul 2024 16:40:20 +0530 Subject: [PATCH 1/4] FLUT-893166-[feature][flutter]: UG corrections --- Flutter/datagrid/scrolling.md | 119 ++++++++++++++++++++-------------- 1 file changed, 72 insertions(+), 47 deletions(-) diff --git a/Flutter/datagrid/scrolling.md b/Flutter/datagrid/scrolling.md index ff1b59edf..c560abe0e 100644 --- a/Flutter/datagrid/scrolling.md +++ b/Flutter/datagrid/scrolling.md @@ -829,57 +829,82 @@ If the height or width of the DataGrid is infinity, then DataGrid sets its heigh import 'package:syncfusion_flutter_datagrid/datagrid.dart'; +class MyMaterialScrollBehavior extends MaterialScrollBehavior { + @override + Widget buildScrollbar( + BuildContext context, Widget child, ScrollableDetails details) { + return Scrollbar( + controller: details.controller, + child: child, + ); + } +} + late EmployeeDataSource _employeeDataSource; +final verticalController = ScrollController(), + horizontalController = ScrollController(); - @override + @override Widget build(BuildContext context) { - return LayoutBuilder(builder: (context, constraints) { - return SingleChildScrollView( - child: SfDataGrid( - shrinkWrapColumns: true, - shrinkWrapRows: true, - source: _employeeDataSource, - columns: [ - GridColumn( - columnName: 'id', - label: Container( - padding: EdgeInsets.symmetric(horizontal: 16.0), - alignment: Alignment.centerRight, - child: Text( - 'ID', - overflow: TextOverflow.ellipsis, - ))), - GridColumn( - columnName: 'name', - label: Container( - padding: EdgeInsets.symmetric(horizontal: 16.0), - alignment: Alignment.centerLeft, - child: Text( - 'Name', - overflow: TextOverflow.ellipsis, - ))), - GridColumn( - columnName: 'designation', - label: Container( - padding: EdgeInsets.symmetric(horizontal: 16.0), - alignment: Alignment.centerLeft, - child: Text( - 'Designation', - overflow: TextOverflow.ellipsis, - ))), - GridColumn( - columnName: 'salary', - label: Container( - padding: EdgeInsets.symmetric(horizontal: 16.0), - alignment: Alignment.centerRight, - child: Text( - 'Salary', - overflow: TextOverflow.ellipsis, - ))), - ], + return Scaffold( + appBar: AppBar( + title: const Text('Syncfusion Flutter DataGrid'), + ), + body: ScrollConfiguration( + behavior: MyMaterialScrollBehavior(), + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + controller: horizontalController, + child: SingleChildScrollView( + controller: verticalController, + scrollDirection: Axis.vertical, + child: SfDataGrid( + source: employeeDataSource, + shrinkWrapColumns: true, + shrinkWrapRows: true, + columns: [ + GridColumn( + columnName: 'id', + label: Container( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + alignment: Alignment.centerRight, + child: const Text( + 'ID', + overflow: TextOverflow.ellipsis, + ))), + GridColumn( + columnName: 'name', + label: Container( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + alignment: Alignment.centerLeft, + child: const Text( + 'Name', + overflow: TextOverflow.ellipsis, + ))), + GridColumn( + columnName: 'designation', + label: Container( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + alignment: Alignment.centerLeft, + child: const Text( + 'Designation', + overflow: TextOverflow.ellipsis, + ))), + GridColumn( + columnName: 'salary', + label: Container( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + alignment: Alignment.centerRight, + child: const Text( + 'Salary', + overflow: TextOverflow.ellipsis, + ))), + ], + ), + ), ), - ); - }); + ), + ); } {% endhighlight %} From 8077a4b962f19ebb4c160f4d1b40026318671b4e Mon Sep 17 00:00:00 2001 From: Abinesh Date: Tue, 16 Jul 2024 09:35:20 +0530 Subject: [PATCH 2/4] FLUT-893166-[feature][flutter]: UG corrections --- Flutter/datagrid/scrolling.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Flutter/datagrid/scrolling.md b/Flutter/datagrid/scrolling.md index c560abe0e..363ecd744 100644 --- a/Flutter/datagrid/scrolling.md +++ b/Flutter/datagrid/scrolling.md @@ -841,8 +841,8 @@ class MyMaterialScrollBehavior extends MaterialScrollBehavior { } late EmployeeDataSource _employeeDataSource; -final verticalController = ScrollController(), - horizontalController = ScrollController(); +final verticalController = ScrollController(); +final horizontalController = ScrollController(); @override Widget build(BuildContext context) { From 8fe78289d22ebe4833577aacbd8b70d61fbfa25e Mon Sep 17 00:00:00 2001 From: Abinesh Date: Tue, 16 Jul 2024 09:42:25 +0530 Subject: [PATCH 3/4] FLUT-893166-[feature][flutter]: UG corrections --- Flutter/datagrid/scrolling.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Flutter/datagrid/scrolling.md b/Flutter/datagrid/scrolling.md index 363ecd744..53423fd09 100644 --- a/Flutter/datagrid/scrolling.md +++ b/Flutter/datagrid/scrolling.md @@ -829,7 +829,7 @@ If the height or width of the DataGrid is infinity, then DataGrid sets its heigh import 'package:syncfusion_flutter_datagrid/datagrid.dart'; -class MyMaterialScrollBehavior extends MaterialScrollBehavior { +class DataGridScrollBehavior extends MaterialScrollBehavior { @override Widget buildScrollbar( BuildContext context, Widget child, ScrollableDetails details) { @@ -841,8 +841,6 @@ class MyMaterialScrollBehavior extends MaterialScrollBehavior { } late EmployeeDataSource _employeeDataSource; -final verticalController = ScrollController(); -final horizontalController = ScrollController(); @override Widget build(BuildContext context) { @@ -851,12 +849,10 @@ final horizontalController = ScrollController(); title: const Text('Syncfusion Flutter DataGrid'), ), body: ScrollConfiguration( - behavior: MyMaterialScrollBehavior(), + behavior: DataGridScrollBehavior(), child: SingleChildScrollView( scrollDirection: Axis.horizontal, - controller: horizontalController, child: SingleChildScrollView( - controller: verticalController, scrollDirection: Axis.vertical, child: SfDataGrid( source: employeeDataSource, From c832dd0a8adb282ed1d1dc2d228124509727db29 Mon Sep 17 00:00:00 2001 From: Abinesh Date: Tue, 16 Jul 2024 12:47:21 +0530 Subject: [PATCH 4/4] FLUT-893166-[feature][flutter]: UG corrections --- Flutter/datagrid/getting-started.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Flutter/datagrid/getting-started.md b/Flutter/datagrid/getting-started.md index d8b9c5588..5728d7bcc 100644 --- a/Flutter/datagrid/getting-started.md +++ b/Flutter/datagrid/getting-started.md @@ -367,12 +367,14 @@ Widget build(BuildContext context) { TextButton( child: Text('Get Selection Information'), onPressed: () { - int selectedIndex = _controller.selectedIndex; - DataGridRow selectedRow = _controller.selectedRow!; - List selectedRows = _controller.selectedRows; - print(selectedIndex); - print(selectedRow); - print(selectedRows); + if (_controller.selectedRows.isNotEmpty) { + int selectedIndex = _controller.selectedIndex; + DataGridRow selectedRow = _controller.selectedRow!; + List selectedRows = _controller.selectedRows; + print(selectedIndex); + print(selectedRow); + print(selectedRows); + } }), Expanded( child: SfDataGrid(