Announcement

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

    Trying to figure out multiple calls to DataArrived

    Hi, i'm experimenting with a new search feature in a grid.

    For reasons, we only show records in a grid that matches a certain criteria, say "banana" should be true.

    we then have a button that triggers the criteria between true and false, and reload records from the server matching this criteria.

    This is how we do it:

    Code:
    public void handleFlipButton() {
        //sets banana = true or false
        grid.setCriteria(getCriteriaForCurrent());
    
        grid.invalidateCache();
    }
    I have then added a onDataArrivedHandler to the grid:
    Code:
    @Override
    public void onDataArrived(DataArrivedEvent dataArrivedEvent) {
        GWT.log("onDataArrived, start:" + dataArrivedEvent.getStartRow() + ", end: " + dataArrivedEvent.getEndRow());
    }

    The issue we have is that the *first* time we flip the criteria and invalidate the cache, i get two calls, one with 0, 0 and then the one with the correct amounts of row from the server.

    Example of log output when we click the button a few times:

    first call to handleFlipButton:
    onDataArrived, start:0, end: 0
    onDataArrived, start:0, end: 10

    second, third, fourth
    onDataArrived, start:0, end: 17
    onDataArrived, start:0, end: 10
    onDataArrived, start:0, end: 17

    The server is only called once each time, also the first.

    What is that first onDataArrived call? I would like it to not happen. It does not represent any data that has arrived :)

    #2
    Hi,

    Not sure about the different log entries, but in general you should not need the call to invalidateCache(), as the criteria change should be enough to trigger a fetch.

    Best regards
    Blama

    Comment

    Working...
    X