[CLOSED] TreeLoader not a constructor

  1. #1

    [CLOSED] TreeLoader not a constructor

    I am using Coolite 0.6. I am trying to extend the TreeLoader to use with my custom rpc call. I just started and have included the RpcTreeLoader.js (my extention ) to the JS files list in the header. Now when I do:

    loader: new Ext.ux.RpcTreeLoader()
    it says RpcTreeLoader is not a constructor !!

    My RpcTreeLoader.js file :

    Ext.namespace("Ext.ux");
    Ext.ux.RpcTreeLoader = function(config){
        Ext.ux.RpcTreeLoader.superclass.constructor.call(this, config);
    };    
    
    Ext.extend(Ext.ux.RpcTreeLoader, Ext.tree.TreeLoader, {
    
     
        load: function(A, B) {
            if (this.clearOnLoad) {
                while (A.firstChild) {
                    A.removeChild(A.firstChild)
                }
            }
            if (this.doPreload(A)) {
                if (typeof B == "function") {
                    B()
                }
            } else {
                if (this.dataUrl || this.url) {                
                    this.requestData(A, B)
                }
            }
        },
        
        doPreload: function(D) {
            if (D.attributes.children) {
                if (D.childNodes.length < 1) {
                var C = D.attributes.children;
                D.beginUpdate();
                for (var B = 0,
                A = C.length; B < A; B++) {
                    var E = D.appendChild(this.createNode(C[B]));
                    if (this.preloadChildren) {
                    this.doPreload(E)
                    }
                }
                D.endUpdate()
                }
                return true
            } else {
                return false
            }
        },
        
        requestData: function(node, callback) {
            
            var callParams;
            var rpc;
            
            if (this.fireEvent("beforeload", this, node, callback) !== false) {
    
    
                callParams = this.getParams(node);
                
                rpc = new JsonRpc({
                    url: GlobalConstants.serverUrl
                });// eo call  
                
                rpc.call({
                    method: 'GetTopLevelOrgEntities',
                    callback: function(success, data, response){Ext.Msg.alert('aaa','ddd')},
                    scope: this                            
                });
            
    
    
                /*************************************
                this.transId = Ext.Ajax.request({
                method: this.requestMethod,
                url: this.dataUrl || this.url,
                success: this.handleResponse,
                failure: this.handleFailure,
                scope: this,
                argument: {
                    callback: B,
                    node: A
                },
                params: this.getParams(A)
                })
    
                *************************************/
    
            } else {
                if (typeof B == "function") {
                B()
                }
            }
        },
        
        /**
        * Override this to add custom request parameters. Default adds the node id as first and only parameter
        */
        
        getParams : function(node) {
            return [node.id];
        }    
    
    });

    and my tree class is :

    var NavTree = {
    
        selectedNode: null, // selectedTreeNode
        rootId: 'rootnode',
        rootText: 'START',
        rootClass: 'treerootnode',
        treeId: 'docoboTree',
        tree: null,
        rootNode: null,
    
    
        //********************************************************************************** 
        //*
        //* init function
        //* makes the first Ajax call to get top level entities from the server 
        //* using the JsonRpc class
        //*
        //**********************************************************************************/
        init: function() {
    
            // Root node configuration
            this.rootNode = new Ext.tree.AsyncTreeNode({
                id: this.rootId,
                text: this.rootText,
                cls: this.rootClass,
                singleClickExpand: true
            });
    
            // Tree panel
            this.tree = new Ext.tree.TreePanel({
                id: this.treeId,
                root: this.rootNode,
                rootVisible: true,
                frame: true,
                animate: true,
                autoScroll: true,
                containerScroll: true,
                loader: new Ext.ux.RpcTreeLoader({})
            });
    
            // render the tree
            this.tree.render('tree');
            this.tree.getRootNode().expand();
    
        }
    
    };                // eo NavTree
    
    //EOF
  2. #2

    RE: [CLOSED] TreeLoader not a constructor

    Hi,

    trailing comma after requestData function

  3. #3

    RE: [CLOSED] TreeLoader not a constructor

    But I do need it there because I have another function getParams following requestData. Anyway I have changed it to :

    RpcTreeLoader = function(config){
        RpcTreeLoader.superclass.constructor.call(this, config);
    };
    
    Ext.extend(RpcTreeLoader, Ext.tree.TreeLoader, {
    and now it is working. Thanks
  4. #4

    RE: [CLOSED] TreeLoader not a constructor

    ah, I did not notice getParams

Similar Threads

  1. Replies: 14
    Last Post: Mar 09, 2010, 12:49 PM
  2. [CLOSED] [1.0] TreeLoader
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Feb 25, 2010, 2:17 PM
  3. Replies: 4
    Last Post: Dec 18, 2009, 6:18 PM
  4. [CLOSED] AsyncTreeNode Treeloader
    By Sharon in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 10, 2009, 11:41 AM
  5. Ext.data.Record constructor
    By mthird in forum 1.x Help
    Replies: 0
    Last Post: Oct 14, 2008, 4:05 PM

Posting Permissions