Remove cells from header on Grid

Hi all! Thanks for reading in advance.

I just wanted to know if there’s a way to remove cells from the HeaderRow. I’ve got this Grid where I can add columns dinamically, and I wanted to implement a way to also remove these columns.

I’m merging the cells on the HeaderRow all the time to make a superior header (something like the first row in this example

When I remove the columns it works ok, they are removed from the Grid, but when I try to add new columns afterwards, it breaks when it tries to merge the next cells (HeaderRow.join()), because on the header these removed columns are still present and it’s causing the breakdown of the app because columns and cells on the header don’t match anymore.

Is there a way to remove cells from the HeaderRow?



From a quick look there seems to be some code for removing the columns from the merged cells that is executed when the column is removed. If it’s failing in your case, it’s most likely a bug. Can you post a simple UI where you see this happening? It would speed up the bug verification and fixing process. You could also open a bug in our


It’s not a 100% working example, but with this you can see already what I’m doing and understand the issue

public class HomeUI extends UI {

    private static final long serialVersionUID = 6392271856720525876L;
    static Navigator navigator;

    SpringViewProvider viewProvider;
    protected void init(VaadinRequest request) {
        getPage().setTitle("UI Test");
        // Create a navigator to control the views
        navigator = new Navigator(this, this);


@SpringView(name = GridTestView.VIEW_NAME)
public class GridTestView extends VerticalLayout implements View {
    public static final String VIEW_NAME = "grid-test";
    public static final  String[] MAIN_FIELDS = new String[]
 { "materialGroup", "materialName", "solidity", "type"};
    public static final  String[] SECONDARY_FIELDS = new String[]
 { "secondary1", "secondary2"};

    Grid grid;
    HeaderRow filteringHeader;
    Button addColumns;
    Button deleteColumns;
    public void enter(ViewChangeEvent event) {
        grid = new Grid();
        grid.setCaption("Double click to edit");

        for(String field : MAIN_FIELDS){
        for (int i = 0; i < 100; ++i) {
            String material_group = "Material Group " + i;
            String material_name = "Material Name " + i;
            String solidity = "Solidity " + i;
            String type = "Type " + i;
            grid.addRow(material_group, material_name, solidity, type);
        addColumns = new Button("Add more columns");
        HeaderRow header = grid.prependHeaderRow();
        header.join((Object[]) MAIN_FIELDS);

        addColumns.addClickListener(new ClickListener() {

            List<String> group_fields = new ArrayList<String>();
            public void buttonClick(ClickEvent event) {
                Random ran = new Random();
                int x = ran.nextInt(6) + 5;
                for(String field : SECONDARY_FIELDS){
                    grid.addColumn(field + "_" + x);
                    group_fields.add(field + "_" + x);                    
                String[] groupFieldsArray = group_fields.toArray(new String[0]
                HeaderRow header = grid.getHeaderRow(0);
                deleteColumns = new Button("Remove Column");
//the header keeps containing the deleted columns so this fails when some columns have been removed
                header.join((Object[]) groupFieldsArray); 

                deleteColumns.addClickListener(new ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        for(String field : groupFieldsArray){
                            grid.removeColumn(field); //this is working OK, it deletes the columns



I opened also a bug ticket on the vaadin trac, but I didn’t get an answer. Not here and no there :frowning:


I haven’t had the time to look at this. Thanks for pinging. I’ll check this later today, and hopefully I can provide some more information to this.


After taking a quick look it seems that joining a column that has been removed seems to cause some issues in there. There’s a missing check in the join method that should verify that the columns exist in Grid and skip them when needed.


Ok then I guess I would need need to keep track of the issue in the trac site to know when the bug is solved right?

Thank you!