Vaadin 8 Grid with Generic list

Hi i am using Vaadin 8.0.1

I am trying to make Vaadin grid common for all of my DataList
And trying to set the Generic Arraylist of Data to Grid its not showing anything to me.

Here is my Grid code.

public class VegaGrid {

private Grid<T> grid;
private T t;
private ArrayList<T> mParentDataList;

public ArrayList<T> getParentDataList() {
    return mParentDataList;
}

public void setParentDataList(ArrayList<T> pParentDataList) {
    this.mParentDataList = pParentDataList;
    System.out.println("size=" + pParentDataList.size());//its printing the sie as 1001
    try {
        ListDataProvider<T> ldp = new ListDataProvider<>(pParentDataList);
        grid.setDataProvider(ldp);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

public VerticalLayout createControls() {
    VerticalLayout v = new VerticalLayout();
    try {
        grid = new Grid<T>();
        grid.setWidth("100%");
        grid.getColumns().stream().forEach(column -> column.setHidable(true));
        grid.setColumnReorderingAllowed(true);
        grid.setSelectionMode(SelectionMode.SINGLE);
        v.addComponent(grid);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return v;
}

}

And Here i am calling the Grid by paasing Arralist of PersonData

ArrayList personDataList = new ArrayList();
for (int i = 0; i <= 1000; i++) {
PersonData p = new PersonData();
p.setId(100);
p.setName(“AAA”);
p.setWeight(50.20);
p.setDob(new Date());
personDataList.add(p);
}

VegaGrid vegaGrid = new VegaGrid<>();
VerticalLayout v=vegaGrid.createControls();
vegaGrid.setParentDataList(personDataList); // Here i am Passing the ListDAta
addComponent(v);

I am getting the grid but not the data inside.
here i am attaching the screen shot

Regards
Nagaraj RC

31320.png

I guess you have to define Columns.
You could do this with “vegaGrid.addColumn(…)” or by using the “new Grid<>(PersonData.class)” constructor.

Nagaraj RC:
Hi i am using Vaadin 8.0.1

I am trying to make Vaadin grid common for all of my DataList
And trying to set the Generic Arraylist of Data to Grid its not showing anything to me.

Here is my Grid code.

public class VegaGrid {

private Grid grid;
private T t;
private ArrayList mParentDataList;

public ArrayList getParentDataList() {
return mParentDataList;
}

public void setParentDataList(ArrayList pParentDataList) {
this.mParentDataList = pParentDataList;
System.out.println(“size=” + pParentDataList.size());//its printing the sie as 1001
try {
ListDataProvider ldp = new ListDataProvider<>(pParentDataList);
grid.setDataProvider(ldp);
} catch (Exception e) {
e.printStackTrace();
}
}

public VerticalLayout createControls() {
VerticalLayout v = new VerticalLayout();
try {
grid = new Grid();
grid.setWidth(“100%”);
grid.getColumns().stream().forEach(column → column.setHidable(true));
grid.setColumnReorderingAllowed(true);
grid.setSelectionMode(SelectionMode.SINGLE);
v.addComponent(grid);
} catch (Exception e) {
e.printStackTrace();
}
return v;
}
}

And Here i am calling the Grid by paasing Arralist of PersonData

ArrayList personDataList = new ArrayList();
for (int i = 0; i <= 1000; i++) {
PersonData p = new PersonData();
p.setId(100);
p.setName(“AAA”);
p.setWeight(50.20);
p.setDob(new Date());
personDataList.add(p);
}

VegaGrid vegaGrid = new VegaGrid<>();
VerticalLayout v=vegaGrid.createControls();
vegaGrid.setParentDataList(personDataList); // Here i am Passing the ListDAta
addComponent(v);

I am getting the grid but not the data inside.
here i am attaching the screen shot

Regards
Nagaraj RC

Hey have you found any solution for this problem. If Yes, could you please guide me too. i am stuck at the exact same point for more than 3 weeks. no response to my query too

Vaadin 7 was rather useful to write things in table in a generic manner i suppose.