Whats the difference between DataTables widget and Tables Widget in Flutter? - flutter

Im going to create an excel like application in Flutter where the user can input a quantity to one of the cells and the app automatically calculate its values based on quantity.
Shall i use DataTables or Tables widget?

Both accept widgets as cell content like TextField, Slider or just Text. Anywhere there are some differences:
Feature
Table
DataTable
Checkbox column
no
showCheckBoxColumn
Set column width
columnWidth
no
Set row height
no
dataRowHeight
Sortable
no
integrated
If a cell with a no this does not mean, its not possible. The feature is just
not directly supported by the widget. In all cases sizes will computed according to Flutters rendering engine: constraints go down, sizes go up.
Anybody please feel free to add more content to above comparison.

Related

Implement a GridView.Count with non scrollable first row and column

So I am implementing sort of a data table in flutter. it shows data based on time in days in rows and some other variant in columns. so naturally, first row is name of the days, and then in first column are values of the other variant. What properties of GridView.count can I use to make first row and column stay fixed when scrolling the grid. so that you can always see the data variants in screen.
I have gone over all properties of GridView.count but I can't find anything.
PS: I don't want to change to something else Like GridView.builder..... because the code is too far gone with how it renders the dynamic data in the rest of rows and columns.
Please Use data table instead of Grid
https://api.flutter.dev/flutter/material/DataTable-class.html.

Flutter - How to link three columns so that they scroll together

I have three columns inside a row. The contents of the columns are generated by a listbuilder getting data from a database. Right now each column scrolls individually but I need them to scroll as one. Is this even possible in flutter or should I have made a gridview instead of three separate columns?
See https://stackoverflow.com/a/54879937/6447123
It works using a NotificationListener<ScrollNotification> plus an independent ScrollController for each scrollable Widget that should be synchronized.
You can use TrackingScrollController too

How do I set a Flutter TableRow in a Table to behave the way Expanded() behaves in a Column?

I have a Table in Flutter and I want to have it expand it's row so that the table takes up the full space that's available for it. Given that TableRow isn't a widget I can't use Expanded on it the way I would for Widgets in a Column. Is there another way to get similar behavior for a Table?
According to my information, you need to use the Row and Columns widgets instead of the Table widget and in addition to using the Expanded widget, or you will need to set a specific height for each row separately and it cannot be Flexible, Using Container in TableRow children

How to create Spreadsheet in Flutter

How to create spreadhseet like Widget in Flutter (only for displaying data).
Currenly I have used Datatable but it does not support 1. fixed header 2. scrollable body.
I want following features:
The headers shoule be fixed.
the body should be scrollable (in both axes)
Currently my Datatable is inside a column > Expanded > SingleChildScrollView(horizontal) > SingleChildScrollView (vertical) > DataTable. Although I am able to scroll the complete Table in both the directions but 1. not simultaneously (i.e. it scrolls either horizontally or vertically), 2. Headers should not scroll, when scrolled vertically.
How can I achieve this ?
It seems that you need scroll controller that allows two or more scroll views to be in sync. In his case, you can use linked_scroll_controller plugin.
You can follow the example in this blog post for a step by step tutorial on how to achieve this.
Sample taken from the blog, check the complete source code here:
Here is an another package for this purpose: syncfusion_flutter_datagrid.
It has several features:
Editing - Allows users to edit cell values.
Sorting - Sort one or more columns in the ascending or descending order.
Stacked headers - Show unbound header rows.
Paging - Load data in segments.
Freeze Panes - Freeze the rows and columns when scrolling the grid.
And more, details in document
However, scrolling simultaneously is something different feature in this case.
You can try InteractiveViewer, but this not recommended in this case. Because both widgets, InteractiveViewer and DataTable, are very powerful widget that may build some conflict.

Jface Table row validation

Background:
I have a Jface table on which I have set Editing support with text cell editor for each column. There are around 20 columns.
Problem:
I want to highlight invalid row field text with dark red color and whole row with light red color.
What I tried as of now:
1. I have highlighted invalid field(single cell of row) using label providers getBackgroundColor() and getForgroundColor().
2. I tried CellEditors setValidator() method to add a validator, but I don't want to clear invalid text from a cell, I just want to highlight it.
3. I have one approach to use a flag for each cell to check the validity of that cell if any of the flags is true will highlight all cells of that row(can be achieved using label providers). But, I think this approach will impact performance for my table.
4. I am not sure performance impact of table updatatestrategy of Jface. So I am not using it.
Reason of highlighting the whole row of the table is: Table have 20+ columns and user don't want to scroll the table to find out problem location.
Please suggest if you know any better solutions.
Using label providers to for the colors is the way to do this.
The label provider is only asked for the color when the row is created or refreshed - by calling one of the viewer refresh or update methods, so this should not impact performance.