But now its so easy. If you want to create paging for your grid, you just have to return the HibernateDataSource with the session and your class for your grid source parameter. Like this :
return new HibernateGridDataSource(session, OrderForm.class);
Its something very simple. But when you're in the middle of something, sometimes its too easy to overcomplicate stuff (Not thinking straight, i previously implements my own GridDataSource for my hibernate class). Everything work out of the box (paging, sorting,etc)
Also the grid has a reset() method for reseting the Sort Ordering.
update :
i found the easiest way to add default column sort for now is by implementing this method.
@Component(id="orderGrid")
private Grid grid;
@SetupRender
void setDefaultSortOrder() {
if(grid.getSortModel().getSortConstraints().isEmpty()) {
// call it twice to make it desc ordered
grid.getSortModel().updateSort("orderDate");
grid.getSortModel().updateSort("orderDate");
}
}
don't forget to reset the sort order to see the result.
update :
i found the easiest way to add default column sort for now is by implementing this method.
@Component(id="orderGrid")
private Grid grid;
@SetupRender
void setDefaultSortOrder() {
if(grid.getSortModel().getSortConstraints().isEmpty()) {
// call it twice to make it desc ordered
grid.getSortModel().updateSort("orderDate");
grid.getSortModel().updateSort("orderDate");
}
}
don't forget to reset the sort order to see the result.