Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

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 Periodically updating a ListGrid is possible in the following ways:

  • Use Using the invalidateCache method. It update This approach updates the data and will show a loading message and . However, this API will disrupt the existing view.
  • Transparent update by DataSource using the fetchData method. It update This method updates the data will not but doesn't show a loading message and will not won't disrupt the existing view.

...

Transparent update

For transparent loading of the data the fetchData method should be used fetchData method.

Code Block
languagejava
titleUpdate by DataSource
linenumbers
true
private void onRefresh() {
    DataSource dataSource = listGrid.getDataSource();
    Criteria criteria = listGrid.getCriteria();

    Integer[] visibleRows = listGrid.getVisibleRows();
    
	// request one page's worth of data on either side of the current viewport
    Integer startRow = visibleRows[0] - listGrid.getResultSet().getResultSize();
    Integer endRow = (visibleRows[1] + listGrid.getResultSet().getResultSize();
    if (startRow < 0) {
        startRow = 0;
    }
    
	DSRequest request = new DSRequest();
    request.setStartRow(startRow);
    request.setEndRow(endRow);
    request.setSortBy(listGrid.getSort());
    
 	dataSource.fetchData(criteria, new DSCallback() {
        @Override
        public void execute(DSResponse response, Object rawData, DSRequest request) {
            DataSource dataSource = listGrid.getDataSource(onRefreshed(response);
        }
    }, request);
}

private void onRefreshed(DSResponse response) {
    
ResultSet	DataSource resultSetdataSource = new ResultSet(dataSourcelistGrid.getDataSource();
    ResultSet resultSet = new ResultSet(dataSource);
    resultSet.setInitialLength(response.getTotalRows());
    
	// correctly position the result in the  resultSet.setInitialData(response.getData());resultset's cache 
    Record[] result =     resultSet.setInitialSort(listGrid.getSort()response.getData();
    Record[] initialData = new Record[response.getTotalRows()];
    System.arraycopy(result, 0, initialData, response.getStartRow(), result.length);
       listGrid.setData(resultSetresultSet.setInitialData(initialData);
    
	resultSet.setInitialSort(listGrid.getSort());
   }
 resultSet.setCriteria(listGrid.getCriteria());
    }, requestlistGrid.setData(resultSet);
}

Attachments

Attachments