Skip to content

Commit 6f96ae4

Browse files
FLUT-883790-[feature][flutter]: RowDetails UG
1 parent 3d17583 commit 6f96ae4

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

Flutter/datagrid/selection.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,83 @@ The Datagrid provides the following callbacks to handle interactions with the ce
12591259
{% endhighlight %}
12601260
{% endtabs %}
12611261

1262+
### Getting row details
1263+
1264+
To retrieve the details of a row in the DataGrid, use the [controller](https://pub.dev/documentation/syncfusion_flutter_datagrid/latest/datagrid/SfDataGrid/controller.html) property. Create an instance of the [DataGridController](https://pub.dev/documentation/syncfusion_flutter_datagrid/latest/datagrid/DataGridController-class.html) and assign it to the controller property of the DataGrid. To obtain the details of a row, use the `getRowDetails` method from the controller, providing the index as the parameter. This method returns a `DataGridRowDetails`, which includes the following properties:
1265+
1266+
* [rowType](https://pub.dev/documentation/syncfusion_flutter_datagrid/latest/datagrid/RowType.html) – Returns the type of the row (e.g., dataRow, headerRow).
1267+
1268+
* [dataGridRow](https://pub.dev/documentation/syncfusion_flutter_datagrid/latest/datagrid/DataGridRow-class.html) – Provides the DataGridRow corresponding to the specified index.
1269+
1270+
* isSelected – Indicates whether the row is currently selected.
1271+
1272+
{% tabs %}
1273+
{% highlight Dart %}
1274+
1275+
@override
1276+
Widget build(BuildContext context) {
1277+
return Scaffold(
1278+
body: Column(
1279+
children: [
1280+
TextButton(
1281+
onPressed: () {
1282+
DataGridRowDetails? details =
1283+
_dataGridController.getRowDetails(4);
1284+
if (details != null) {
1285+
print(details.rowType);
1286+
print(details.dataGridRow);
1287+
print(details.isSelected);
1288+
}
1289+
},
1290+
child: Text('Get row details')),
1291+
Expanded(
1292+
child: SfDataGrid(
1293+
source: employeeDataSource,
1294+
controller: _dataGridController,
1295+
columns: <GridColumn>[
1296+
GridColumn(
1297+
columnName: 'id',
1298+
label: Container(
1299+
padding: EdgeInsets.all(16.0),
1300+
alignment: Alignment.center,
1301+
child: Text('ID'),
1302+
),
1303+
),
1304+
GridColumn(
1305+
columnName: 'name',
1306+
label: Container(
1307+
padding: EdgeInsets.all(8.0),
1308+
alignment: Alignment.center,
1309+
child: Text('Name'),
1310+
),
1311+
),
1312+
GridColumn(
1313+
columnName: 'designation',
1314+
label: Container(
1315+
padding: EdgeInsets.all(8.0),
1316+
alignment: Alignment.center,
1317+
child: Text('Designation'),
1318+
),
1319+
),
1320+
GridColumn(
1321+
columnName: 'salary',
1322+
label: Container(
1323+
padding: EdgeInsets.all(8.0),
1324+
alignment: Alignment.center,
1325+
child: Text('Salary'),
1326+
),
1327+
),
1328+
],
1329+
),
1330+
),
1331+
],
1332+
),
1333+
);
1334+
}
1335+
1336+
{% endhighlight %}
1337+
{% endtabs %}
1338+
12621339
## Customizing selection behavior
12631340

12641341
To perform custom actions apart from the functionalities mentioned in the above tables for key press actions of the keyboard, implement your custom actions in the [handleKeyEvent()](https://pub.dev/documentation/syncfusion_flutter_datagrid/latest/datagrid/RowSelectionManager/handleKeyEvent.html) override of the custom written selection manager class derived from [RowSelectionManager](https://pub.dev/documentation/syncfusion_flutter_datagrid/latest/datagrid/RowSelectionManager-class.html) and assign it to the [SfDataGrid.selectionManager](https://pub.dev/documentation/syncfusion_flutter_datagrid/latest/datagrid/SfDataGrid/selectionManager.html) property.

0 commit comments

Comments
 (0)