Comments (5)
Hi @divan ,
Based on the provided details, the rowColumnIndex obtained from DataGridSource.buildGroupCaptionCellWidget represents solely the row and column index of the caption summary row. Whenever the caption summary row is expanded or collapsed, the rowColumnIndex changes according to the visible rows. This rowColumnIndex is derived from the internal grouped collection.
When using this rowColumnIndex to access the actual data object within grouped rows, we kindly request additional clarification on the expected behavior, along with clear examples and the necessary scenarios from your end. This will significantly aid us in further investigating and promptly providing an appropriate solution.
Regards,
Abinesh P
from flutter-widgets.
@abineshPalanisamy thank you for prompt reply! Here is a quick example. I put some explanation in the buildGroupCaptionCellWidget
function comments. My real app case is a bit different (I need to display custom widget for custom type of the common group field), but this example is showing the point.
Currently this code throws an exception, because rowIndex
indeed points to 4th internal grouped row, and data
has only 3 items. What I'm looking for is to the way to get to single/any/all objects from actual data for the given group.
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_datagrid/datagrid.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'DataGrid Group Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(),
);
}
}
class Employee {
Employee(this.id, this.name, this.designation, this.salary);
final int id;
final String name;
final String designation;
final int salary;
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
late EmployeeDataSource _employeeDataSource;
List<Employee> _employees = <Employee>[];
@override
void initState() {
super.initState();
_employees = getEmployeeData();
_employeeDataSource = EmployeeDataSource(employees: _employees);
_employeeDataSource
.addColumnGroup(ColumnGroup(name: 'designation', sortGroupRows: true));
}
List<Employee> getEmployeeData() {
return [
Employee(10003, 'Lara', 'Designer', 15000),
Employee(10004, 'Michael', 'Designer', 15000),
Employee(10001, 'James', 'Project Lead', 20000),
];
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SfDataGrid(
source: _employeeDataSource,
columnWidthMode: ColumnWidthMode.fill,
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,
))),
],
),
);
}
}
class EmployeeDataSource extends DataGridSource {
List<Employee> employees = [];
EmployeeDataSource({required this.employees}) {
dataGridRows = employees
.map<DataGridRow>((dataGridRow) => DataGridRow(cells: [
DataGridCell<int>(columnName: 'id', value: dataGridRow.id),
DataGridCell<String>(columnName: 'name', value: dataGridRow.name),
DataGridCell<String>(
columnName: 'designation', value: dataGridRow.designation),
DataGridCell<int>(
columnName: 'salary', value: dataGridRow.salary),
]))
.toList();
}
List<DataGridRow> dataGridRows = [];
@override
List<DataGridRow> get rows => dataGridRows;
@override
DataGridRowAdapter? buildRow(DataGridRow row) {
return DataGridRowAdapter(
cells: row.getCells().map<Widget>((dataGridCell) {
return Container(
alignment: (dataGridCell.columnName == 'id' ||
dataGridCell.columnName == 'salary')
? Alignment.centerRight
: Alignment.centerLeft,
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Text(
dataGridCell.value.toString(),
overflow: TextOverflow.ellipsis,
));
}).toList());
}
@override
Widget? buildGroupCaptionCellWidget(
RowColumnIndex rowColumnIndex, String summaryValue) {
// get the Employee object of the first person for this group
// to find a salary
final idx = rowColumnIndex.rowIndex;
print('> rowIndex is $idx');
Employee employee = employees[idx];
String text = 'Salary of the first person is ${employee.salary}';
return Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 15),
child: Text(
text,
));
}
}
Output is:
flutter: > rowIndex is 4
Another exception was thrown: RangeError (index): Invalid value: Not in inclusive range 0..2: 4
from flutter-widgets.
I guess one of the solution might be to use {{Key}}
as a summary, and then manually search my underlying data by this value. What I don't like about this approach is the need to convert to/from String, as `summaryString' is a string only...
from flutter-widgets.
Hi @divan ,
As of now, We have already considered your request to support for accessing the grouped rows in the DataGridSource.buildGroupCaptionCellWidget function as a feature. We will implement this feature in any of our upcoming releases. At the planning stage for every release cycle, we review all open features and identify features for implementation based on specific parameters including product vision, technological feasibility, and customer interest. We appreciate your patience and understanding until then. You can follow up with the below feedback for further details,
Feedback link: 50278
Regards,
Abinesh P
from flutter-widgets.
Hi @divan,
We're closing this issue as of now. You can follow up through the provided feedback link. If you need any further assistance, kindly reopen this issue. We're always happy to help you!
Regards,
Ashok K
from flutter-widgets.
Related Issues (20)
- Resource View in Vertical HOT 1
- Add RTL support to PdfPageLayoutMode.single HOT 2
- deselect the selected row using a keyboard shortcut HOT 1
- Please upgrade device_info_plus ^9.0.2 to ^10.0.1 HOT 2
- Issue with Tooltip Behavior on mobile click. HOT 1
- [Crash!!!] Some data may cause the App to crash on iOS HOT 2
- [syncfusion_flutter_datagrid] Filter for List<T> column type HOT 1
- Failed to find Platform SDK with path: platforms;android-31 HOT 2
- Issue while peview PDF HOT 6
- Performance issues on Flutter 3.22.2 HOT 5
- syncfusion_flutter_datagrid prevent Ctrl+V into editable cell by CustomSelectionManager HOT 1
- Rendering issue when compiling with --wasm HOT 2
- merged cells HOT 1
- Syncfusion Flutter PDF Viewer (26.1.42) Fails to Load PDF Generated by Syncfusion Flutter PDF HOT 5
- [syncfusion_flutter_signaturepad] Is there any way to change signature image size? HOT 1
- Handshake Exception on jpg file url HOT 1
- Unable to customize appointment widget size when give appointmentDisplayCount as 1 HOT 2
- Error (Xcode): ../../.pub-cache/hosted/pub.dev/syncfusion_flutter_pdfviewer-26.1.42/lib/src/form_fields/pdf_signature.dart:590:25: Error: Couldn't find constructor 'WidgetStatePropertyAll'. HOT 1
- RangeError (index): Invalid value: Not in inclusive range HOT 1
- Label is unstanble HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter-widgets.