L. Lowe
L. Lowe

Reputation: 1

Don't Want Loading Image while Srting or Paging in GWT 2.4 CellTable

I am using GWT 2.4 and have created a CellTable:

    table = new CellTable<Home>();
    pager = new SimplePager(SimplePager.TextLocation.LEFT);

    idColumn = new TextColumn<Home>() {
        @Override
        public String getValue(Home home) {
            return home.getHomeId();
        }
    };

    idColumn.setSortable(true);

    TextColumn<Home> addressColumn = new TextColumn<Home>() {
        @Override
        public String getValue(Home home) {
            return home.getAddress();
        }
    };


    postcodeColumn = new TextColumn<Home>() {
        @Override
        public String getValue(Home home) {
            return home.getPostcode();
        }
    };

    postcodeColumn.setSortable(true);

    TextColumn<Home> productColumn = new TextColumn<Home>() {
        @Override
        public String getValue(Home home) {
            return home.getProduct();
        }
    };

    table.addColumn(uriColumn, "");
    table.addColumn(idColumn, "HomeID");
    table.addColumn(addressColumn, "Address");
    table.addColumn(postcodeColumn, "Postcode");
    table.addColumn(productColumn, "Product");

    table.setVisibleRange(0,10);

    pager.setDisplay(table);

    final AsyncDataProvider<Home> dataProvider = new HomesDataProvider();

    // Connect the list to the data provider.
    dataProvider.addDataDisplay(table);

    ColumnSortEvent.AsyncHandler columnSortHandler = new ColumnSortEvent.AsyncHandler(table);

    table.addColumnSortHandler(columnSortHandler);

    // default sort on the home id
    table.getColumnSortList().push(idColumn);

which, as you can see also uses an AsyncDataProvider to fetch the data and a SimplePager to paginate.

The AsyncDataProvider is as follows:

private class HomesDataProvider extends AsyncDataProvider<Home> {

    @Override
    protected void onRangeChanged(HasData<Home> homeData) {
        final int start = homeData.getVisibleRange().getStart();
        int length = homeData.getVisibleRange().getLength();

        final ColumnSortList sortList = table.getColumnSortList();
        JSONObject searchParametersJson = null;

        if (sortList != null && sortList.size() > 0) {
            ColumnSortList.ColumnSortInfo sortColumn = sortList.get(0);
            String sortDirection = (sortColumn.isAscending()) ? "asc" : "desc";
            Column<?, ?> column = sortColumn.getColumn();
            int sortColumnIndex = -1;

            if (column.equals(idColumn)) {
                sortColumnIndex = 2;
            } else if (column.equals(postcodeColumn)) {
                sortColumnIndex = 4;
            }

            searchParametersJson = getSearchCallParameters(start, length, sortColumnIndex, sortDirection);

        } 

        RPC.fetchHomes(searchParameters, CookieManager.getUsername(), new CallbackAction<SearchResultList<Home>>() {
            @Override
            public void execute(SearchResultList<Home> results) {
                if (results != null && results.getResultList().size() > 0) {
                    updateRowCount(results.getTotalRecords(), true);
                    updateRowData(start, results.getResultList());


                } 
            }
        });

    }
}

The table displays fine and the data is correct. The problem is that when I click to sort a column or to view another page on the pager, the loading image appears until the data has loaded. The client has said this is too jerky and distracting and he would rather the display change from the old set of rows to the new set of rows without clearing down the table first, as demonstrated in the showcase http://samples.gwtproject.org/samples/Showcase/Showcase.html#!CwCellTable. How can I do this?

I tried table.setLoadingIndicator(null); and this stops the spinner from appearing but it still clears the table before loading the new data.

Upvotes: 0

Views: 50

Answers (0)

Related Questions