proxy.getReader() function undefined on tree store Ext Direct proxy when Ext code is built/minified but NOT when running from app.js

StackOverflow https://stackoverflow.com/questions/23071405

Question

The getReader() function is called in various places in the Ext.data.TreeStore class. This function is found to be undefined when the my application is minified, but is defined when running from source that is not minified.

setRootNode()

onNodeAdded()

onBeforeNodeExpand()

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

etc...

In my application, I have a store that is extending the Ext.data.TreeStore class. The application fails because it can't find that getReader() function. That's because I've created a custom proxy in my store to make Ext Direct calls.

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'
    }
},

How can I define that getReader() function, so the code doesn't fail? Or why would it not have access to that function?

When minified, it doesn't seem to have access to Ext.define('Ext.data.proxy.Proxy' > getReader(). The code is slighly different just before the constructor call of the custom store (which extends Ext.data.TreeStore). But I am unable to put a breakpoint on this code in Firefox when I click it.

Using versions:

Ext JS 4.2

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

Call Stack (starting from top of stack):

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

search for ".getProxy().getReader().buildExtractors(true);" to get the call it fails on...

===========

2 setRootNode line (when minified):

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

[3] Ext.data.TreeStore constructor line (when minified):

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

[4] callParent line (when minified):

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] custom store that extends Ext.data.TreeStore (when minified):

(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 (when minified):

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

===========

The only difference between being minified and non-minified is that the minified version runs the extjs framework and the application code from a single file (all-classes.js). When it's not minified, the ext-all-debug.js (or whatever flavor of the framework), each file within the "app" folder, and the app.js are separate files.

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

Edit:

Okay, if I examine e in minified (aka me in unminified)...

e.proxy.getReader() doesn't exist

me.proxy.getReader() does exist

enter image description here

enter image description here

Edit #2:

The problem is that e.proxy (or e.getProxy() from the code) is of the type 'Ext.tree.Panel' .... but in the unminified version, me.proxy (or me.getProxy() from the code) is of the type 'Ext.data.proxy.Direct'. Question is, how did this happen?

Was it helpful?

Solution

I needed to reset the proxy in the constructor of the store using this.setProxy({new proxy}). The default was Ext.tree.Panel.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top