You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How can i make a table's header or column fixed #21165
I've tried making some changes to the workaround, I'm looking to make only the header row sticky (fixed). I have some issues when scrolling, the header row scrolling is out of sync with the data table.
This is happening because the top table (header) and main table have different sizes and column count. That makes them out of sync.
Looking at DataTable code i've found out that the width is build using tableColumns[displayColumnIndex] = const IntrinsicColumnWidth(flex: 1.0); to make them dynamic acordingly to the content.
I updated my answer on StackOverflow with a CustomDataTable where you can set the data to fill the table, set the width of the cells, and set an optional fixed column / fixed row. I think with this you can get an idea of how to improve it: Fixed column and row header for DataTable on Flutter Dart
Reacted by Gustavo Garcia, Kismet , Mohammad and Abdulrahman Qabbout
Hi @pablobarrera, I'm trying to follow your solution, how can we use the _rowsCells, _fixedColCells, and _fixedRowCells ? As these are not widget list.
I updated the custom widget to receive any lists of data and an optional cellBuilder, you can see in the example how to use it. I also added the option to set the height of the cells. Fixed column and row header for DataTable on Flutter Dart
I won't keep improving it because is just a workaround, as I mentioned in the answer, we're hiding headers of DataTable. It would be good if we could remove headers on DataTable, so this could be a better solution. Anyway, you're free to use it and improve it the way you want.
JIC, I've taken appart DataTable and PaginatedDataTable, made the changes to fix top/header row and published these versions as a separate package: https://pub.dev/packages/data_table_2
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
zoechi commentedon Aug 30, 2018
Please consider asking in one of the channels http://flutter.io/support .
okjesse commentedon Sep 1, 2018
Thank you~~
werytert commentedon Apr 18, 2019
So, how can i do it? i cant understand
Goostavo commentedon Oct 24, 2019
I have the same need. We are working on making some kind of workaround using DataTable and external scroll controllers.
You can follow and contribute to the thread here:
StackOverflow Thread
kismet- commentedon Oct 24, 2019
I've tried making some changes to the workaround, I'm looking to make only the header row sticky (fixed). I have some issues when scrolling, the header row scrolling is out of sync with the data table.
Goostavo commentedon Oct 24, 2019
Nice work!
This is happening because the top table (header) and main table have different sizes and column count. That makes them out of sync.
Looking at DataTable code i've found out that the width is build using
tableColumns[displayColumnIndex] = const IntrinsicColumnWidth(flex: 1.0);to make them dynamic acordingly to the content.On the end it uses:
I'll try to fork the DataTable object and use this
columnWidthspablobarrera commentedon Oct 24, 2019
I updated my answer on StackOverflow with a
CustomDataTablewhere you can set the data to fill the table, set the width of the cells, and set an optional fixed column / fixed row. I think with this you can get an idea of how to improve it:Fixed column and row header for DataTable on Flutter Dart
kismet- commentedon Oct 24, 2019
Hi @pablobarrera, I'm trying to follow your solution, how can we use the
_rowsCells,_fixedColCells, and_fixedRowCells? As these are not widget list.pablobarrera commentedon Oct 25, 2019
I updated the custom widget to receive any lists of data and an optional cellBuilder, you can see in the example how to use it. I also added the option to set the height of the cells.
Fixed column and row header for DataTable on Flutter Dart
I won't keep improving it because is just a workaround, as I mentioned in the answer, we're hiding headers of DataTable. It would be good if we could remove headers on DataTable, so this could be a better solution. Anyway, you're free to use it and improve it the way you want.
kf6gpe commentedon Jan 6, 2020
Closing as this discussion should occur on Stack Overflow or one of our support channels at http://flutter.dev/support. Thanks for using Flutter!
deadsoul44 commentedon Mar 23, 2020
Could you please reopen the issue? It should be possible to fix table header.
lukele1607 commentedon Jul 16, 2020
Please reopen this issue.
maxim-saplin commentedon Apr 24, 2021
JIC, I've taken appart DataTable and PaginatedDataTable, made the changes to fix top/header row and published these versions as a separate package: https://pub.dev/packages/data_table_2
edilson14 commentedon Jun 17, 2021
i found this, it solve my problem
github-actions commentedon Jul 31, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.