You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using a dgrid to access a cached Rest store (observable is not part of the equation).
In _StoreMixin, a new collection is created, and stored in _renderedCollection:
However, this has implications when refresh()ing the grid.
If you put() a value into the original collection passed to the dgrid, the collection's cache is updated with the new item (obviously). This is all fine. However, if you then issue a refresh() to the grid, the "main" collection is not actually used -- instead, this._renderedCollection is used. At this point, this._renderedCollection has its queries cached. So, rerunning the query will use this._renderedCollection's cache, which will result in the result being returned -- without the newly added value.
After modifying the grid, when I want to refresh its data, I am doing this:
This ensures that query caches are neutralised for the _renderedCollection. But, it feels hacky.
Please note that you can say "Well, simply use canCacheQuery to prevent caching", but that would not be a solution: there would be no use case left for querying to happen at all in a dgrid! (Unless you are happy for partial results to be displayed all the time)
I hope this made sense.
The text was updated successfully, but these errors were encountered:
mercmobily
changed the title
Caching a dgrid implies that stale cache prevents reload() from newly added elements
Dev 0.4: Caching a dgrid implies that stale cache prevents reload() from newly added elements
Jun 5, 2014
Hi there,
I am using a dgrid to access a cached Rest store (observable is not part of the equation).
In _StoreMixin, a new collection is created, and stored in _renderedCollection:
https://github.com/SitePen/dgrid/blob/dev-0.4/_StoreMixin.js#L116-L128
However, this has implications when
refresh()
ing the grid.If you
put()
a value into the original collection passed to the dgrid, the collection's cache is updated with the new item (obviously). This is all fine. However, if you then issue a refresh() to the grid, the "main" collection is not actually used -- instead,this._renderedCollection
is used. At this point,this._renderedCollection
has its queries cached. So, rerunning the query will usethis._renderedCollection
's cache, which will result in the result being returned -- without the newly added value.After modifying the grid, when I want to refresh its data, I am doing this:
This ensures that query caches are neutralised for the
_renderedCollection
. But, it feels hacky.Please note that you can say "Well, simply use
canCacheQuery
to prevent caching", but that would not be a solution: there would be no use case left for querying to happen at all in a dgrid! (Unless you are happy for partial results to be displayed all the time)I hope this made sense.
The text was updated successfully, but these errors were encountered: