Search code examples
eclipseeclipse-pluginnattable

How to save column order and the width of the re-sized columns after changing the size of columns in NAT table into the prefernce


How to save Column order and width after changing their position and size ?

  • re-sized column width should be persisted and used in the subsequent sessions (and also considered during export/import preferences usecase)
  • any change in the column position should be persisted and used in the subsequent sessions (and also considered during export/import preferences usecase)

Q1. How can I get the column width of the nattable after changing the width by dragging/double click event ?
- I want this with original column position even after the column is not in the original order.
Q2. How can I get the column order, after re-order using drag and drop?


Solution

  • Answer to Q1: Ask the layers, they have getWidth() and getColumnWidthByPosition(int) methods

    Answer to Q2: Typically you will need to check the ColumnReorderLayer directly.

    But if you want to store and load NatTable states, you should have a look at the persistence mechanism provided by NatTable. I wrote an article about this and it is even documented on the NatTable website.