pylover
pylover

Reputation: 8055

How to Extend/Override a predefined core sencha class?

I need to apply some changes into extjs 4.x core library to supports right-to-left direction in rendering.i already know its not good to manipulate the ExtJS code directly.

My question is: How to do this via another js file that loaded into page after the ext-all.js ?

its possible to change a predefined sencha class method by calling Ext.apply() ?

Upvotes: 3

Views: 3410

Answers (2)

Sourabh86
Sourabh86

Reputation: 744

It is even easier if you are using Sencha Architect. This article explains both approaches.

Upvotes: 2

Izhaki
Izhaki

Reputation: 23586

It really depends what exactly you need to modify. But I believe you meant the following.

I have a file called ext-mods.js, which is loaded after ext-all.js:

Ext.onReady(function(){

    Ext.override( Ext.data.writer.Json, {
         // We want all records sent to the server be encoded as an array,
         // even if there's a single record
         allowSingle:    false,

         // We only want to send what have changed
         writeAllFields: false
    });

});

I have changed the default config for all Json Writers, but you can equally override methods (by copying the code from the library and then apply your modifications).

Upvotes: 3

Related Questions