View Full Version : Is it possible to make an Ext.data.Record class which extends Observable?

20 Aug 2015, 8:20 PM
Hi all,

I have a class in our ExtJS 3 application which we create from Ext.data.Record because these objects will be used with a Store. We create the class like so:

Portal.data.DataCollection = function() {
var constructor = Ext.data.Record.create([]);

constructor.prototype.getTitle = function() {
// ...

// ... add more methods the same way

return constructor;

I now want to have this class extend Ext.util.Observable so I can have instances of it fire and listen to events. However, the normal way I would so this is to create my class by using Ext.extend(superclass, overrides) and that is not applicable in this case, given how my DataCollection class is created. So my question is: is there a way to have my DataCollection class extend Observable and still be a Ext.data.Record? or, alternatively, is there a way, once I have my instances of DataCollection, to make them implement the Observable functionality?

Any help is appreciated as I am aware how woefully out-of-date we are with our ExtJS major versions!


27 Oct 2015, 8:51 PM
If anyone is interested, I wrote a utility class which takes any JavaScript object and effectively makes it implement Observable, even if it's prototype didn't. See https://github.com/aodn/aodn-portal/blob/43d949ecd691369c5ae99a6ffdb0c902152c9fa6/web-app/js/portal/utils/ObservableUtils.js