Nov 24, 2008, 7:00 AM
[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:
My RpcTreeLoader.js file :
and my tree class is :
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