List<GridColumn> get getColumns {
return [
GridColumn(
columnName: 'id',
label:
Container(alignment: Alignment.center, child: const Text('ID'))),
GridColumn(
columnName: 'name',
label:
Container(
alignment: Alignment.center, child: const Text('Name'))),
GridColumn(
columnName: 'designation',
label:
Container(
alignment: Alignment.center, child: const Text('Designation'))),
GridColumn(
columnName: 'salary',
label:
Container(
alignment: Alignment.center, child: const Text('Salary'))),
];
}
class EmployeeDataSource extends DataGridSource {
EmployeeDataSource(List<Employee> employees) {
buildDataGridRow(employees);
}
void
buildDataGridRow(List<Employee> employeeData) {
dataGridRow =
employeeData.map<DataGridRow>((employee) {
return
DataGridRow(cells: [
DataGridCell<int>(columnName: 'id', value: employee.id),
DataGridCell<String>(columnName: 'name', value: employee.name),
DataGridCell<String>(
columnName: 'designation', value: employee.designation),
DataGridCell<int>(columnName: 'salary', value: employee.salary),
]);
}).toList();
}
}
|