Skip to content

[syncfusion_flutter_datagrid] shows only 5 rows bug! #584

@mohamed-okaily

Description

@mohamed-okaily

As shown in the preview below the table only shows the first 5 rows!
Screenshot 2022-03-30 085652

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];
  }
}

@monolidth

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions