Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add a method to a singleton in ExtJS4?

This is the ExtJS Shape Class:

Ext.define('Ext.chart.Shape', {

    singleton: true,

    circle: function (surface, opts) {
        return surface.add(Ext.apply({
            type: 'circle',
            x: opts.x,
            y: opts.y,
            stroke: null,
            radius: opts.radius
        }, opts));
    },
    ...
});

I want to add a method to this Class. For example:

myCircle: function (surface, opts) {
        return ...
},

How can I do this?

like image 225
Vahid Avatar asked Dec 03 '25 19:12

Vahid


1 Answers

I found the answer. This is the solution if someone needs it:

Ext.define('MyShape', {
    override: 'Ext.chart.Shape',

    initialize: function() {
        this.callOverridden(arguments);
    },

    myCircle: function (surface, opts) {
        return ...
    }
});
like image 199
Vahid Avatar answered Dec 06 '25 10:12

Vahid



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!