Reordering columns and rows in a table
It is very user-friendly
if users can adjust components by themselves. One such component is a Table
. There are situations where some users want to see the name of items in the first column, other users want to see IDs, other users want to see prices, and so on. In other cases, the user can set, for example, the priority of items by reordering rows. If the row is above, it has a higher priority. In this recipe, we will see how to allow a user to reorder columns and rows in a table.
How to do it...
Carry out the following
steps to allow reordering columns and rows in the Table
:
We create a Vaadin project with a main UI class called
Demo
as follows:public class Demo extends UI {…}
We need a bean item for the data table container. We create the same bean as created in the Lazy loading in a table recipe.
Next, we create our
ReorderTable
class which extends theTable
class.public class ReorderTable extends Table {…}
For the table container, we use the
BeanItemContainer...