Description
ListGrid displays a list of objects in a grid, where each row represents one object and each cell in the row represents one property.
Periodical updating ListGrid is possible in the following ways:
- Use invalidateCache method. It update the data will show a loading message and will disrupt the existing view.
- Transparent update by DataSource using fetchData method. It update the data will not show a loading message and will not disrupt the existing view.
Transparent update
For transparent loading the data should be used fetchData method.
Update by DataSource
private void updateAll() { DataSource dataSource = listGrid.getDataSource(); Criteria criteria = listGrid.getCriteria(); dataSource.fetchData(criteria, createUpdateAllCallback()); }
Handle server response
private DSCallback createUpdateCallback() { return new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { DataSource dataSource = listGrid.getDataSource(); ResultSet resultSet = new ResultSet(dataSource); resultSet.setInitialLength(response.getTotalRows()); resultSet.setInitialData(response.getData()); listGrid.setData(resultSet); } }; }
Transparent update range
For transparent loading the data range should be used DSRequest. It allows you to specify a range of data to load.
Update by DataSource
private void updateRange() { DataSource dataSource = listGrid.getDataSource(); Criteria criteria = listGrid.getCriteria(); Integer[] visibleRows = listGrid.getVisibleRows(); Integer startRow = 0; Integer endRow = (visibleRows[1] + listGrid.getResultSet().getResultSize()); DSRequest request = new DSRequest(); request.setStartRow(startRow); request.setEndRow(endRow); dataSource.fetchData(criteria, createUpdateCallback(), request); }