NatTable was originally written by Andy Tsoi and dedicated to his girlfriend, Natalie.
We also sometimes think of 'Nat' as an acronym for 'Not A Table' given that it's really more of a data grid, or a tool for building tables/grids.
As much as you want, pretty much. The only practical limit right now is that the number of columns, rows, width and height of your table must be able to be represented as 32-bit integers. We test against virtual data sets of 1 million columns by 1 million rows.
You can either create an instance of ComboBoxCellEditor with a given list of values (which results in a static combobox) or with an instance of a custom IComboBoxDataProvider. By creating and using a custom IComboBoxDataProvider you are able to load the content of the combobox at runtime. As IComboBoxDataProvider.getValues(int, int) gets the column and row index of the cell for which the combobox should be rendered, it is possible to get information out of other cells to determine which content the combobox should contain.
Create custom IComboBoxDataProvider to return different lists regarding other cell values
Register a ComboBoxCellEditor with the custom IComboBoxDataProvider
NatTable supports the autoresize feature on double clicking cell edges. Unfortunately the
existing commands related to that feature doesn't work if they are fired programmatically
on building the NatTable. This is because when firing the command, the NatTable isn't rendered
yet, so the calculation of the width is returning the wrong values.
But there is another possibility how to achieve autoresizing columns. The TextPainter which is used for rendering cell content as text, can be configured to calculate the column width/row height. Modifying the default configuration the following way will resize the columns on rendering the content, so the content can be shown completely. Also note that if the content contains line breaks, the row height will be calculated also.
Modifying the DefaultNatTableStyleConfiguration to use a TextPainter that calculates cell width/height as cell painter
The TextPainter solution has one downsite. If the cell content is not a
long text but a long word that can't be wrapped, it is not possible to manually resize the cell
anymore to show the content cutted.
There is another downsite if the table is editable. The cells will automatically resize if the cell content which defines the cell width is modified to be longer/shorter. In fact this can also be a requirement, but compared to other well known grids, this behaviour is rather unexpected.
In the SourceForge forum josecho2005 found a solution that only does the autoresize after rendering is finished. With some slight modifications it looks like this. You can find the original post here.
Adding a listener that autoresizes the NatTable after rendering is finished and removes itself after that
In the Eclipse forum Jay Norwood posted a similar solution which also works for larger tables
where you need to scroll the content. To understand why this is needed, you have to remember
that the NatTable is a virtual table. This means that only the content is processed that is
visible. So you can't do an autoresize on columns that aren't visible. So the following solution
is remembering which columns/rows where already autoresized. This way the autoresize isn't
called again for the same column/row if you scroll or resize the view that contains the NatTable.
The listener need to be active all the time and shouldn't be removed then.
This solution also introduces the IOverlayPainter of the NatTable. Implementations of this interface can be added to the NatTable. They will be called after the rendering of the NatTable is finished. You can find the original post here.
Adding an IOverlayPainter that autoresizes the NatTable after rendering is finished and on scrollingAlthough this solution works for larger tables, this is not a usual use case and can cause some side effects or unexpected behaviour in resizing. We suggest to don't do automatic resizing on larger tables where the user needs to scroll. Other well known grid/table applications doesn't support that either and leave the sizing of columns/rows to the user who is looking at it.