Announcement

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

    fetch data for a single row in a ListGrid

    Hi,

    I want to fetch data for a single row in a ListGrid, so it keeps the row selected and shows the latest data from the server but does not fetch all rows in the grid. I've tried a variety of things but und up resorting to invalidateCache and then trying to re-select the same row. That's clunky for my needs and causes rendering to appear choppy. So I'd really like to just tell the grid to fetch data for a specific row. Is that a feature of ListGrid?

    Thanks,
    -chris


    #2
    Use DataSource.fetchData() with the PK of the record in question as the criteria, and feed the resulting record to DataSource.updateCaches() as part of an "update" DSResponse.

    Comment


      #3
      Does the code below look right?
      I think it's doing what you described, but the row doesn't visibly change.

      The ISC console shows that the fetch only gets the matching record.
      No errors are logged.

      Code:
      final ListGridRecord selectedRecord = grid.getSelectedRecord();
      grid.getDataSource().fetchData(
                 new Criterion("id", OperatorId.EQUALS, selectedRecord.getAttribute("id")),
                 new DSCallback() {
                      @Override
                      public void execute(DSResponse dsResponse, Object o, DSRequest dsRequest) {
                          dsResponse.setOperationType(DSOperationType.UPDATE);
                          grid.getDataSource().updateCaches(dsResponse);
                      }
                  });

      Comment


        #4
        You shouldn't try to repurpose the existing DSResponse as it has a lot of settings and metadata on it that makes no sense with updateCaches(). Just create a new, clean DSResponse with the same record.

        Other than that the approach looks fine, but of course you haven't shown any logs or RPC Tab data so we can't help troubleshoot yet.

        Comment


          #5
          Thanks for the help. Creating a new UPDATE DSResponse with the data works great.

          Comment

          Working...
          X