Observable doesn't work properly on paged data

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Observable doesn't work properly on paged data

neville1355
Hey all,

I wanted to ping the community before I file a bug with dojo and/or dgrid. Basically, I have an OnDemandGrid with several pages of rows. As you scroll the dgrid, it will observe the data on screen so it can reflect updates as needed.

It seems like the observe() callbacks on the wrong pages are being called and treat the item as a new entry. This is causing my rows from page 1 to jump to the bottom of page 2 (as if it were new).

I simplified the problem to just the Observable, and you can find the demonstration of the issue here:
http://jsfiddle.net/TmddB/

As you can see, I have two pages and both observe callbacks are fired when I issue a put(). The first one is correct but the second observe callback has removedFrom as -1 which gets treated as a new record.

Any suggestions on how to get around this?
Reply | Threaded
Open this post in threaded view
|

Re: Observable doesn't work properly on paged data

Kenneth G. Franqueiro
This seems like it could be a legit bug in dojo/store/Observable.  I
would note that it seems like the issue goes away if you change the
second query to not have a count that surpasses the actual end of the
result set.

--Ken

On 8/9/2013 4:52 PM, neville1355 wrote:

> Hey all,
>
> I wanted to ping the community before I file a bug with dojo and/or dgrid.
> Basically, I have an OnDemandGrid with several pages of rows. As you scroll
> the dgrid, it will observe the data on screen so it can reflect updates as
> needed.
>
> It seems like the observe() callbacks on the wrong pages are being called
> and treat the item as a new entry. This is causing my rows from page 1 to
> jump to the bottom of page 2 (as if it were new).
>
> I simplified the problem to just the Observable, and you can find the
> demonstration of the issue here:
> http://jsfiddle.net/TmddB/
>
> As you can see, I have two pages and both observe callbacks are fired when I
> issue a put(). The first one is correct but the second observe callback has
> removedFrom as -1 which gets treated as a new record.
>
> Any suggestions on how to get around this?
>
>
>
> --
> View this message in context: http://dojo-toolkit.33424.n3.nabble.com/Observable-doesn-t-work-properly-on-paged-data-tp3998481.html
> Sent from the Dojo Toolkit mailing list archive at Nabble.com.
> ________________________________________________________
> Dojo Toolkit: http://dojotoolkit.org/
> Tutorials: http://dojotoolkit.org/documentation/
> Reference Guide: http://dojotoolkit.org/reference-guide
> API Documentation: http://dojotoolkit.org/api
>
> [hidden email]
> To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
>
________________________________________________________
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/
Reference Guide: http://dojotoolkit.org/reference-guide
API Documentation: http://dojotoolkit.org/api

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Observable doesn't work properly on paged data

Stefan Bird
I can verify that Observable doesn't properly honour start or count; basically
it does not maintain the window and will notify you about changes to any
objects that match the query whether or not they are within your window.

I always assumed this was by design (since there's no attempt in the code to
account for the window), and fixing it will probably be quite complex; for a
start operations that add/remove an item will sometimes need to fire two events
- one for the object being added/removed, and another for the object that gets
pushed out/pulled into the window.

Because Observable sits on a generic store and is not itself a fully-fledged
view, it doesn't have enough information to do this properly without
requerying the underlying store. For example, let's say an item that matches
the query is removed. If its old index in our sorted query was less than
start, we should slide our window to the right, so we need to fetch the item
that would now have index start+count. Similarly if an item is added before
our window, we need to slide it to the left.

It would be nice to have a solution for this, and in the past I have resorted
to writing custom stores that have an Observer interface that understands
windows, but I've not had time to write a generic version yet.

Another nice to have (again on my very long to-do list) would be a View
wrapper (similar to Observable), where query() returns an object that
implements the store interface, allowing you to create views of a store and
pass them around as if they were stores themselves.

On Fri, 9 Aug 2013 19:14:57 Kenneth G. Franqueiro wrote:

> This seems like it could be a legit bug in dojo/store/Observable.  I
> would note that it seems like the issue goes away if you change the
> second query to not have a count that surpasses the actual end of the
> result set.
>
> --Ken
>
> On 8/9/2013 4:52 PM, neville1355 wrote:
> > Hey all,
> >
> > I wanted to ping the community before I file a bug with dojo and/or dgrid.
> > Basically, I have an OnDemandGrid with several pages of rows. As you
> > scroll
> > the dgrid, it will observe the data on screen so it can reflect updates as
> > needed.
> >
> > It seems like the observe() callbacks on the wrong pages are being called
> > and treat the item as a new entry. This is causing my rows from page 1 to
> > jump to the bottom of page 2 (as if it were new).
> >
> > I simplified the problem to just the Observable, and you can find the
> > demonstration of the issue here:
> > http://jsfiddle.net/TmddB/
> >
> > As you can see, I have two pages and both observe callbacks are fired when
> > I issue a put(). The first one is correct but the second observe callback
> > has removedFrom as -1 which gets treated as a new record.
> >
> > Any suggestions on how to get around this?
> >
> >
> >
> > --
> > View this message in context:
> > http://dojo-toolkit.33424.n3.nabble.com/Observable-doesn-t-work-properly-> > on-paged-data-tp3998481.html Sent from the Dojo Toolkit mailing list
> > archive at Nabble.com.
> > ________________________________________________________
> > Dojo Toolkit: http://dojotoolkit.org/
> > Tutorials: http://dojotoolkit.org/documentation/
> > Reference Guide: http://dojotoolkit.org/reference-guide
> > API Documentation: http://dojotoolkit.org/api
> >
> > [hidden email]
> > To unsubscribe, visit:
> > http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
> ________________________________________________________
> Dojo Toolkit: http://dojotoolkit.org/
> Tutorials: http://dojotoolkit.org/documentation/
> Reference Guide: http://dojotoolkit.org/reference-guide
> API Documentation: http://dojotoolkit.org/api
>
> [hidden email]
> To unsubscribe, visit:
> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
________________________________________________________
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/
Reference Guide: http://dojotoolkit.org/reference-guide
API Documentation: http://dojotoolkit.org/api

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: Observable doesn't work properly on paged data

neville1355
This post was updated on .
Thanks for your replies.

So it seems there is a legitimate shortcoming with Observable and paged queries.

Couldn't the fix be something as simple as..
if(removedFrom === -1 && existingId)
{
 return;
}

Basically, if we didn't find this item in the paged result set and there's an existing id -> assume that it's on another page.

I'll need to think about this some more to see if this breaks other functionality.

Edit: I suppose this would break operations where an item moves from one page to another. Maybe a more specific solution is needed in my dgrid implementation
Reply | Threaded
Open this post in threaded view
|

Re: Observable doesn't work properly on paged data

neville1355
I've logged a bug here:
https://bugs.dojotoolkit.org/ticket/17376

I'll try to fix this locally in the mean time.