Search code examples
extjsextjs4

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() ?


Solution

  • 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).