The correct answer is Sergey Makarov . This answer contains additional information.
User reordering
You can allow the user to drag and drop columns in the table to reorder them at run time. To enable this function, call isColumnReorderingAllowed .
You can use the listener to get information about the occurrence of such a reordering event.
User reordering lasts only for this work session. If you want to maintain the order of users in future work sessions, you must somehow maintain your desired order and apply the order when creating the table again.
Loss of order
If you replace the table data source, the column order will be reset. You can get the current order before the change, and then restore. The following is sample code.
// Visible status & ordering. java.lang.Object[] visibleColumns = this.exampleTable.getVisibleColumns(); // ------| Fresh Data |-------------- // Put fresh data into the Table. this.exampleTable.setContainerDataSource( freshBeanItemContainer ); // ------| Restore Config |-------------- // Visible status & ordering. this.exampleTable.setVisibleColumns( visibleColumns ); // Assumes the table has the same properties.
By the way, as with visibility and order, when minimized, it will also reset with fresh data. You can track and restore collapse of a column, as well as order.
source share