Question

I have a grid store and I am able to get modified data using

var modifiedData = store.getModifiedData();

Now I want to get deleted records (I am using ExtJs 3).

I tried using var deletedData = store.getRemovedRecords(); but I guess this property is available in ExtJs 4.

I just want to fetch the records that are deleted from the grid. Any help would be appreciated.

Était-ce utile?

La solution

By default this is not possible.

ExtJS 3.x is only capable of tracking modified records (out of the box). Deleted (removed) records get removed completely. But there is one thing you can do; The store will fire the remove event for each record with the record itself as second argument. You may use this to create your own array of removed records. The implementation would be really simple I guess. You can do it per instance or create a whole new storetype by extending. But I guess the later is not really needed here.

Here is a example. Note that you might need take care of other events to clear the removedList.

var myStore = new Ext.data.Store({
    removedList: [],
    listeners: {
        clear: function(store) {
              store.removedList =  [];
        },
        load: function(store) {
              store.removedList =  [];
        },
        remove: function(store, record, index) {
              store.removedList.push(record);
        }
    }
});
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top