v23 Grid without bean (urgent)

Hello everyone. I want to create a grid with two columns that doesn‘t have any specific bean. Both columns should be filled by different List Objects.
Thanks alot in advance!

That’s not how Grid works. You need to combine both Lists logically

As knoobie said, that will probably save you a lot or troubles to create a bean with the 2 String and an id.

hmm how do you think i should/could do that?:sweat_smile:
cause pretty much one string is the key and the other is the value

cause what i pretty much did was:

————

Grid grid = new Grid<>();
grid.addColumn(item → item).setHeader(„Key“);

grid.addColumn(item → item).setHeader(„Value“);

————

and because i had 2 columns, i couldn‘t do „grid.setItems(…)“

List<Integer> ids = new ArrayList<>();
        List<String> names = new ArrayList<>();
        List<MyBean> beans = new ArrayList<>();
        for (int i = 0; i < ids.size(); i++) {
            beans.add(new MyBean(ids.get(0), names.get(0)))
        }

    public static class MyBean {

        private final Integer id;
        private final String name;

        public MyBean(@NotNull Integer id, String name) {
            this.id = id;
            this.name = name;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;

            MyBean myBean = (MyBean) o;

            return id.equals(myBean.id);
        }

        @Override
        public int hashCode() {
            return id.hashCode();
        }
    }

i‘ll try it out, thanks!

i my case, the ids don‘t exist. i have like attribute names which are strings. How should i create a bean that has two string objects?

sorry for the weird questions, feel like my brain is fried​:joy::sweat_smile:

cause pretty much one string is the key and the other is the value
Just replace the list of ids by the list of the keys. And yes the bean will have 2 strings

thanks :)

so i‘m currently doing something like this:

———
List myBeanList = new ArrayList<>();
myBeanList.add(new MyBean(key, value));
———

so far everything works fine but the grid doesn‘t show the content

———
Grid myBeanGrid = new Grid<>(MyBean.class, false);
myBeanGrid.addColumn(MyBean::getKey).setHeader(„Key“);
myBeanGrid.addColumn(MyBean::getValue).setHeader(„Value“);
———

the table gets created but there‘s no data in there. Did i forget to do anything?

myBeanGrid.setItems(myBeanList); needs to by done somewhere. Otherwise the Grid doesn’t know what to display

realized aswell, thanks😅