Grid IndexOutOfBoundsException using FetchCallback and CountCallback when d

Hello,

I have a grid that retrieves data from a database using a DataProvider. The data can be filtered, so when the filters change in the user interface, I call dataProvider.refreshAll();

Everything works fine except when the data changes over time. Let’s say I filter on Status = Pending. If the records do not change while I scroll through the items, no problem. But if one of the records that was initially “pending” changes to “Completed” (it no longer fulfills the condition of the filter). I get an IndexOutOfBoundsException exception.

My fetchCallback calls the database because data is in batch. I’m not working in memory.

How can I solve the issue ?

Hi there,

So what is happening is that your CountCallback for a given filter is returning a certain number, let’s say 100, but then when you actually fetch the items, one of them had its status changed and the number of items returned is, for example 99, which causes errors on the DataProvider mechanism. Is that correct?

If so, it looks like a bug in the DataProvider.

Can you create a ticket for us to investigate and fix it? The repository is https://github.com/vaadin/flow/issues

Thanks a lot!

As for a workaround fix for the issue, you cloud return empty items as placeholders for those items that were changed. Not ideal, though.

Yes, that’s exactly the case. I think the bug is more in the Grid. It should be able to handle cases where you receive less (or more) records from the DataProvider that expected.

I’ll try the placeholders workaround just to avoid exceptions.

May or may not be about Grid - all the classes related to DataProvider, DataCommunicator and DataGenerator are part of the flow-data project though (which is in the flow repository). We have other components that also use the same mechanism, for example IronList. Chances are that the bug is more related to flow-data than to Grid… but don’t worry, we will move the ticket to the right place if needed.