Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FLUT-893166 - [Others]: Flutter DataGrid UG correction #912

Open
wants to merge 4 commits into
base: hotfix/hotfix-v26.1.35
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions Flutter/datagrid/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,14 @@ Widget build(BuildContext context) {
TextButton(
child: Text('Get Selection Information'),
onPressed: () {
int selectedIndex = _controller.selectedIndex;
DataGridRow selectedRow = _controller.selectedRow!;
List<DataGridRow> selectedRows = _controller.selectedRows;
print(selectedIndex);
print(selectedRow);
print(selectedRows);
if (_controller.selectedRows.isNotEmpty) {
int selectedIndex = _controller.selectedIndex;
DataGridRow selectedRow = _controller.selectedRow!;
List<DataGridRow> selectedRows = _controller.selectedRows;
print(selectedIndex);
print(selectedRow);
print(selectedRows);
}
}),
Expanded(
child: SfDataGrid(
Expand Down
115 changes: 68 additions & 47 deletions Flutter/datagrid/scrolling.md
Original file line number Diff line number Diff line change
Expand Up @@ -829,57 +829,78 @@ If the height or width of the DataGrid is infinity, then DataGrid sets its heigh

import 'package:syncfusion_flutter_datagrid/datagrid.dart';

class DataGridScrollBehavior extends MaterialScrollBehavior {
@override
Widget buildScrollbar(
BuildContext context, Widget child, ScrollableDetails details) {
return Scrollbar(
controller: details.controller,
child: child,
);
}
}

late EmployeeDataSource _employeeDataSource;

@override
@override
Widget build(BuildContext context) {
return LayoutBuilder(builder: (context, constraints) {
return SingleChildScrollView(
child: SfDataGrid(
shrinkWrapColumns: true,
shrinkWrapRows: true,
source: _employeeDataSource,
columns: <GridColumn>[
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: DataGridScrollBehavior(),
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: SfDataGrid(
source: employeeDataSource,
shrinkWrapColumns: true,
shrinkWrapRows: true,
columns: <GridColumn>[
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 %}
Expand Down