Grid displays only one column

Beginners question, I apologize in advance. Using Vaadin 24.3.10, I create a Grid like follows:

usersGrid = new Grid<>();
usersGrid.setItems(newFesUsersDataProvider());
final Column<FesUser> userIdColumn = 
    usersGrid.addColumn(FesUser::getUserId).setHeader(User Id);
userIdColumn.setVisible(true);
userIdColumn.setKey(userId);
final Column<FesUser> nameColumn = 
    usersGrid.addColumn(FesUser::getName).setHeader(Name);
nameColumn.setVisible(true);
nameColumn.setKey(name);

Looks fine to me, but when I open the page, only the first column (“User Id”) is being displayed.

Are there any suggestions, what might go wrong, or what I could investigate?

Thanks,

Jochen

Assuming you used the Spring starter my working code looks like this

package com.example.application.views.helloworld;

import com.example.application.views.MainLayout;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.grid.Grid.Column;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.router.RouteAlias;

@PageTitle("Hello World")
@Route(value = "", layout = MainLayout.class)
@RouteAlias(value = "", layout = MainLayout.class)
public class HelloWorldView extends HorizontalLayout {

    public static class User{
        String name;
        String id;
        public User(String name, String id){this.name=name;this.id=id;}
        public String getName(){return name;}
        public String getId(){return id;}
    }

    public HelloWorldView() {

        Grid<User> usersGrid = new Grid<User>();
        usersGrid.setItems( 
            new User("Bob", "1"),
            new User("Alice", "2")
         );
        final Column<User> userIdColumn = 
            usersGrid.addColumn( User::getId ).setHeader("User Id");
        userIdColumn.setVisible(true);
        userIdColumn.setKey("userId");
        final Column<User> nameColumn = 
            usersGrid.addColumn(User::getName).setHeader("Name");
        nameColumn.setVisible(true);
        nameColumn.setKey("name");
        add(usersGrid);
    }

}

This is a long shot, but assuming you used a starter, make sure “name” is not the preexisting “private TextField name;” as I am not sure what are strings without quotation marks or variables in your example.