在树存储上未定义的proxy.getReader()函数在构建/缩小Ext代码时的Ext Direct代理但从app.js运行时不是

时间:2014-04-14 22:18:31

标签: extjs proxy extjs4 datareader

在Ext.data.TreeStore类的各个地方调用getReader()函数。当我的应用程序被缩小时,发现此函数未定义,但是在从未缩小的源运行时定义此函数。

setRootNode()

onNodeAdded()

onBeforeNodeExpand()

... when loading the store (setRootNode() is called automatically if rootVisible: false)

etc...

在我的应用程序中,我有一个扩展Ext.data.TreeStore类的商店。应用程序失败,因为它找不到getReader()函数。那是因为我在我的商店中创建了一个自定义代理来进行Ext Direct调用。

constructor: function(config) {

    Ext.applyIf(this.proxy, {
        directFn: CRUD.read
    });

    this.callParent([config]);
},

proxy: {
    type: 'direct',        
    reader: {
        root: 'data',
        type: 'json'
    },        
    extraParams: {
        encrypted_id: '0',
        node_id: '0'
    }
},

如何定义getReader()函数,所以代码不会失败?或者为什么它不能访问该功能?

当缩小时,它似乎无法访问Ext.define('Ext.data.proxy.Proxy'> getReader()。代码在构造函数调用自定义存储之前略有不同(其中扩展Ext.data.TreeStore)。但是当我点击它时,我无法在Firefox中为这段代码添加断点。

使用版本:

Ext JS 4.2

Sencha Cmd v3.1.2.342 (when running "sencha app build" to minify source)

调用堆栈(从堆栈顶部开始):

[1] getReader() function < [2] setRootNode < [3] constructor < [4] callParent < [5] constructor < .... can't read two stack items ... < [8] instantiate()

搜索“.getProxy()。getReader()。buildExtractors(true);”接到电话失败......

===========

2 setRootNode行(缩小时):

d.getProxy().getReader().buildExtractors(true);

[3] Ext.data.TreeStore构造函数行(缩小时):

if (b) {
  delete e.root;
  e.setRootNode(b)  // this line
} 

[4] callParent line(缩小时):

Ext.apply(b, {
   ...
   b.implement({
      ...
      callParent: function (g) {
         var h, e = (h = this.callParent.caller) && (h.$previous || ((h = h.$owner ? h : h.caller) && h.$owner.superclass[h.$name]));
         return e.apply(this, g || d)  // this line
      }, 

[5]扩展Ext.data.TreeStore的自定义商店(缩小时):

(Ext.cmd.derive("MyApp.store.custom.MyTreeStoreNodes", Ext.data.TreeStore, {
   ...
   constructor: function (a) {
      Ext.applyIf(this.proxy, {
         directFn: CRUD.read
      });
      this.callParent([a]);  // this line

[8]实例化(缩小时):

instantiate: function () {
   ...
   return this.getInstantiator(j.length)(i, j)  // this line

===========

缩小版本和非缩小版本之间的唯一区别是缩小版本从单个文件(all-classes.js)运行extjs框架和应用程序代码。当它没有缩小时,ext-all-debug.js(或框架的任何风格),“app”文件夹中的每个文件和app.js都是单独的文件。

=============

编辑:

好吧,如果我在缩小的时候检查e(也就是未经明确的我)...

e.proxy.getReader()不存在

me.proxy.getReader()确实存在

enter image description here

enter image description here

编辑#2:

问题是e.proxy(或代码中的e.getProxy())的类型是'Ext.tree.Panel'....但是在未公开的版本中,me.proxy(或me.getProxy)代码中的())类型为'Ext.data.proxy.Direct'。问题是,这是怎么发生的?

1 个答案:

答案 0 :(得分:0)

我需要使用this.setProxy({new proxy})重置商店构造函数中的代理。默认为Ext.tree.Panel。