-
Notifications
You must be signed in to change notification settings - Fork 773
Closed
Description
As shown in the preview below the table only shows the first 5 rows!

The bug happens only when wrapping the table inside a ListView Widget!!
Code example below:
class _TableTestState extends State<TableTest> {
@override
Widget build(BuildContext context) {
var _columns = ["ID", "Name"];
List<Demo> tableUtils = [
Demo(1, "name1"),
Demo(2, "name2"),
Demo(3, "name3"),
Demo(4, "name4"),
Demo(5, "name5"),
Demo(6, "name6"),
Demo(7, "name7"),
Demo(8, "name8"),
Demo(9, "name9"),
Demo(1, "name1"),
Demo(2, "name2"),
Demo(3, "name3"),
Demo(4, "name4"),
Demo(5, "name5")
];
TableSource _dataTable =
TableSource(data: tableUtils);
return Scaffold(
body: ListView(
children: [
//any other widgets ...
Expanded(
child: SfDataGrid(
defaultColumnWidth: 150,
columnWidthMode: ColumnWidthMode.fill,
source: _dataTable,
columns: List<GridColumn>.generate(_columns.length, (index) {
return GridColumn(
columnName: _columns[index],
label: Text(_columns[index]),
);
}),
),
),
],
),
);
}
}
class TableSource extends DataGridSource {
TableSource({required List<Demo> data}) {
_tableData = List<DataGridRow>.generate(data.length, (rv) {
return DataGridRow(
cells: List<DataGridCell>.generate(data[rv].data().length, (index) {
return DataGridCell(
columnName: data[rv].data()[index].toString(),
value: data[rv].data()[index]);
}));
}).toList();
}
List<DataGridRow> _tableData = [];
@override
List<DataGridRow> get rows => _tableData;
@override
DataGridRowAdapter buildRow(DataGridRow row) {
return DataGridRowAdapter(
cells: List<Widget>.generate(row.getCells().length, (index) {
return Text(row.getCells()[index].columnName);
}).toList());
}
}
class Demo {
int id;
String name;
Demo(this.id, this.name);
List<dynamic> data() {
return [id, name];
}
}
Metadata
Metadata
Assignees
Labels
No labels