Hey!
I'm using the SfDataGrid to show a simple editable table. I am also setting a footer, just to use as a spacer so my FAB won't hide the last row in the table:
As you can see there is a grid line at the bottom of the footer, and I don't like it being there - it just doesn't make sense for what I'm trying to do. Is there any way in which I can hide it?
Thanks!
Hi Ido,
By default, the footer is laid inside the DataGrid i.e., at the bottom of the DataGrid. So, the DataGrid horizontal gridline is applied to the DataGridRow as well as the footer. It’s a behaviour of the DataGrid. Also, DataGrid doesn’t have support for hiding the footer bottom border alone. In your case, you can achieve your requirement by wrapping the DataGrid with Expanded and SizedBox inside the Column widget. You can set the required height for SizedBox for the spacer. Please check the following code snippet.
|
@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Flutter SfDataGrid'), ), body: Column( children: [ Expanded( child: SfDataGrid( source: _employeeDataSource, columns: getColumns, selectionMode: SelectionMode.multiple, columnWidthMode: ColumnWidthMode.fill), ), const SizedBox(height: 70), ], ), floatingActionButton: FloatingActionButton( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)), onPressed: () {}, child: const Icon(Icons.add)), floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, ); } } |
We hope this helps. Please provide more details in case we misunderstood your requirement. It will be helpful for us to check on it and provide you the solution at the earliest.
Regards,
Tamilarasan
Thanks for the reply!
Although what you have mentioned does get rid of the bottom grid line, it creates another problem:
There is now a constant footer behind the FAB, which hides the DataGrid. What I wish to have is just 'another row' in the table, with the correct height, so the FAB won't hide all the rows ab
Hi Ido,
Based on the provided information, we are unable to reproduce the reported issue. It’s working fine on our end. We have tested the following sample. In that sample, we set the SizedBox with the required height for the spacer to avoid hiding the DataGrid rows by the FAB. Please check the following code snippet. Can please provide the simple sample that is reproducible to check further?
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/sample-194077145
Regarding Query: What I wish to have is just 'another row' in the table, with the correct height, so the FAB won't hide all the rows ab.
Please confirm if you want to add a footer or another row (for spacer) without a bottom border at the end of the last row alone instead of a constant footer. It will be helpful for us to check on it and provide you with the solution at the earliest.
Regards,
Tamilarasan
"Please confirm if you want to add a footer or another row (for spacer) without a bottom border at the end of the last row alone instead of a constant footer. It will be helpful for us to check on it and provide you with the solution at the earliest. "
That is exactly what I'm trying to have - I don't want a constant footer, I want another blank row that acts as a spacer.
Hi Ido,
As we already said in the previous update, the DataGrid doesn’t have support for hiding the footer or last row bottom border alone. You can achieve your requirements with the workaround i.e., setting the borders manually by following these steps,
Step 1: Set the gridLinesVisibility to GridLinesVisibility.none
Step 2: In the DataGridSource.buildRow method, you can set the border for the individual cell. In the Container.decoration property, set the bottom border for the DataGridRows. We have prepared the sample for that. Please check the following sample and code snippet.
|
@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Flutter SfDataGrid'), ), body: Container( margin: const EdgeInsets.all(50), child: SfDataGrid( source: _employeeDataSource, columns: getColumns, columnWidthMode: ColumnWidthMode.fill, gridLinesVisibility: GridLinesVisibility.none, footerHeight: 100, footer: const SizedBox(), ), ), floatingActionButton: FloatingActionButton( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)), onPressed: () {}, child: const Icon(Icons.add)), floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, ); }
In buildRow method:
@override DataGridRowAdapter? buildRow(DataGridRow row) { return DataGridRowAdapter( cells: row.getCells().map<Widget>((dataGridCell) { return Container( decoration: BoxDecoration( border: Border( bottom: BorderSide(width: 1.0, color: Colors.grey.withOpacity(0.45)), )), alignment: Alignment.center, child: Text( dataGridCell.value.toString(), )); }).toList()); } |
Sample Link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/sample-143295379
We hope this helps. Please let us know if you need further assistance.
Regards,
Tamilarasan
Wow, thanks!
This would be a great small feature to add to the library!
Hi Ido,
We are glad that the provided response meets your requirement. Please let us know if you need further assistance. As always, we are happy to help you out.
Regarding Query: This would be a great small feature to add to the library!
We have already considered your request “customize the individual cell borders” as a feature. This feature will be implemented in any of our upcoming release. We will let you know when this feature is implemented. You can follow up with the below feedback for further details,
Feedback Link: https://www.syncfusion.com/feedback/34101/support-to-customize-the-individual-cell-borders
Regards,
Tamilarasan