swtjfacenattablenebula

How to get currently active column and data from Nebula NatTable


If I hide some column and sort the data, how to extract this new information from NatTable. There is no API to extract from NatTable instance like JFace table viewer.

Like JFace we can get this information using follwing API

tableViewer.getTable().getColumns();
tableViewer.getTable().getItems();

Solution

  • First question, how do you hide a column in JFace TableViewer? I am not aware of that feature.

    You need to understand that NatTable is a viewer on a set of data. If you need information about the underlying data, ask the underlying data model. Or iterate over the columns and rows (there is API to get the column/row count and the column/row by position). But be aware that you only can get what you see on a NatTable layer. If you need the real underlying data you need to go down the layer stack.

    So no, there is no direct API on NatTable level to get the information you want. As the NatTable has a virtual nature by design and abstracts the shown information, this is not available. NatTable shows data in a transformed way, it does not transform the underlying data itself.