Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    #16
    Thanks for your reply!

    The problem was something else:
    I have an if-clause around my RPC-call. I forgot to set an empty TileRecord array to the response and process the call, if the clause is not fulfilled.
    Because of that the next call of executeFetch(), which responds data was not handled correct.

    Comment


      #17
      Most efficient method for TileGrid Update

      Smart GWT: v8.3p_2012-11-25/PowerEdition Deployment (built 2012-11-25)

      Firefox: 18.0.2

      Piggy-backing off the previous post since it's definitely related and the last post was more than 3 years ago...so I'm wondering if there's any updates.

      I have a Tile Grid tied to a datasource. It shows around ~30 images. As time goes on, more images are saved on the server and i want the Tile grid to periodically refresh to show these so the user doesn't have to constantly click a "Refresh" button.

      I wrapped the following code inside a repeating timer. Unlike with ListGrids or TreeGrids it doesn't seem like updating the caches on a TileGrid's datasource will cause new tiles to appear.

      [CODE]
      final int[] selectedIndexs = new int[_tileGrid.getSelection().length];

      for (int i = 0; i < _tileGrid.getSelection().length; i++)
      selectedIndexs[i] = _tileGrid.getRecordIndex(_tileGrid.getSelection()[i]);

      _tileGrid.getDataSource().fetchData(getGridCriteria(), new DSCallback() {

      @Override
      public void execute(DSResponse response, Object rawData, DSRequest request) {

      _tileGrid.invalidateCache();

      _tileGrid.setData(response.getData());

      _tileGrid.selectRecords(selectedIndexs);
      }
      });
      [CODE]

      Few questions:

      1) Is there a reason TileGrid doesn't support a selectedState string like both ListGrid and TileGrid? Right now I am looping through indexes and saving them and then re-selecting them.

      2) Is invalidateCache above required to ensure all new data is shown in the tile grid? I feel like this is reducing performance and efficiency but may be necessary to get new data form server.

      3) Is there a more efficient method to show updated images since I'm always just adding an image or two to the tile grid every few seconds? Should I just query the backend datasource for new images and add them manually to the tileGrid?

      Thanks for any help or insight anyone can provide!

      Comment


        #18
        As an update, I just checked and although I could've sworn it wasn't working before, it now seems like you can call updateCaches on the tilegrid.

        Working pseudocode:

        saveSelectionState (still not as nice as listgrid)

        tileGrid.datasource.fetchdata(criteria, callback {

        request.setOperationType(DSOperationType.UPDATE);

        tileGrid.getDataSource().updateCaches(response, request);

        restore selection state
        }

        Is this still the most efficient way to update periodically?

        Comment

        Working...
        X