Dgrid 0.4 and dstore: update row in UI without put request

982 Views Asked by At

In Dgrid 0.3.16 I was using an Observable store and when my data in the store was changed I called the store notify function. (not 'put' because I need only an UI update, this is a specific case)

store.notify(object, existingId);

I have now upgraded Dgrid to version 0.4 and I'm using 'dstore' as the store. The store is created like this:

        var store = new declare([ Rest, SimpleQuery, Trackable, Cache, TreeStore ])(lang.mixin({
            target:"/ac/api?fetchview",
            idProperty:"$uniqueid", 
            useRangeHeaders: true
        }, config));

        store.getRootCollection = function (parent, options) {
            return this.root.filter({parent: parent.$position},options);
        };

        store.getChildren = function (parent, options) {
            return this.root.filter({parent: parent.$position},options);
        };

        store.mayHaveChildren = function (item) {
            return item.$iscategory;
        };

        this.collection = store;

How do I notify the store when one row is changed without calling 'put'? I need dGrid to re-render the row.

1

There are 1 best solutions below

3
On BEST ANSWER

dstore follows a model more similar to typical event-driven approaches with on and emit methods. dstore supports add, update and delete events - the first two expect an object with a target property referencing the item; the delete event expects an object with an id property referencing the item's identity.

So to notify of an updated item, call store.emit('update', { target: updatedItem }).

The emit method is documented under Store methods, and the types of events are further enumerated in the Collection documentation.