How to Extend/Override a predefined core sencha class?

ぃ、小莉子 提交于 2019-12-12 13:43:44

问题


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


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/13615817/how-to-extend-override-a-predefined-core-sencha-class

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!