Opened 7 years ago

Closed 4 years ago

#15228 closed defect (fixed)

dojo.store.Observable does not update paged result set correctly on item add or remove

Reported by: Justin Doherty Owned by: Kris Zyp
Priority: undecided Milestone: 1.9
Component: Data Version: 1.7.2
Keywords: Cc:
Blocked By: Blocking:

Description

On an Observable wrapped store if I create a result set with start and count options the result set does not get updated correctly when an item is added or removed from the result set.

I've also noted that the result set does not get updated at all if there is not at least one observer on it, I believe the result set should be updated to reflect correct state regardless of the presence of an observer.

If you run the test code below you will notice that the length of the result set is 4 after the removal, I would expect the results to contain the next item in the store to fall into the result set.

If you comment out the store.remove line and uncomment the store.add call you will see the result set will contain 6 items now.

Lastly, if you remove the "results.observe();" line the result set never actually gets updated at all, it will contain the removed item or it will not contain added item.

require([
    "dojo/store/Memory",
    "dojo/store/Observable",
    "dojo/_base/array"
    ], function(Memory, Observable, array) {
    var numItems = 10;
    var data = [];
    for (var i = 0; i < numItems; i++) {
        data.push({
            id: i,
            label: "Label: " + i
        });
    }
    var store = Observable(new Memory({
        data: data
    }));
    var results = store.query(function() {
        return true;
    }, {
        start: 0,
        count: 5,
        sort: [{
            attribute: "label"}]
    });
    results.observe();
    alert(results.length);
    store.remove(0);
/*
    store.add({
        id: numItems,
        label: "Label: 1a"
    });
        */
    alert(results.length);
});

Change History (2)

comment:1 Changed 5 years ago by dylan

I believe this was also fixed in 1.9. Kris, can you verify please?

comment:2 Changed 4 years ago by dylan

Milestone: tbd1.9
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.