GWT CellTable provides almost all what a developper wants from a table: paging, sorting, data binding,..etc. However, customizing the header/footer is not provided out of the box, and there is only few resources online that describes how. In this tutorial, we will go through how to customize the CellTable header with components such as buttons and textfields, and also how to change the span of header cells. same thing applies to footers.
First of all, lets create a Cell table with some sample data. We are going to use a DTO such as:
We can then create our table in the entry point class:
Our table now looks like:
Suppose we need to customize the header ( thead in HTML terms) by adding two rows: the first spans over two cells and has a button, and the second one has two cells one with a textfield and the other one with a list. To customize a CellTable header, we need to extend the abstract class AbstractHeaderOrFooterBuilder
Finally, we need to set our new header builder in the cell table we created: