Hi,
I have the following grid where its columns are created with the addColumn() function.
public class MyGrid extends Grid {
public MyGrid () {
setSizeFull();
setSelectionMode(SelectionMode.NONE);
addColumn(“Task”, String.class);
getColumn(“Task”).setSortable(false);
addColumn(“SubTask”, String.class);
getColumn(“SubTask”).setSortable(false);
for (int i=0; i<24; i++) {
// add 24 cols corresponding to the 24 hours of a day
String columnTimeLabel = String.valueOf(i) + ":00";
addColumn(columnTimeLabel, String.class);
getColumn(columnTimeLabel).setSortable(false);
}
fillGridWithData();
}
public void fillGridWithData(){
// here getData() is a function that returns the grid data
String [] [26]
gridData = getData();
for (int i = 0; i<gridData .length; i++){
String gridRowData[26]
= gridData[i]
;
addRow(gridRowData);
}
}
}
public class GridView extends VerticalLayout implements View {
private MyGrid grid;
public GridView () {
setSizeFull();
grid = new MyGrid ();
addComponent(grid);
}
}
My question is how can I refresh the data in MyGrid if at some point getData() returns a new set of data?