Book Image

Vaadin 7 Cookbook

Book Image

Vaadin 7 Cookbook

Overview of this book

Table of Contents (19 chapters)
Vaadin 7 Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

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:

  1. We create a Vaadin project with a main UI class called Demo as follows:

    public class Demo extends UI {…}
  2. 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.

  3. Next, we create our ReorderTable class which extends the Table class.

    public class ReorderTable extends Table {…}
  4. For the table container, we use the BeanItemContainer...