X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..92c2b89db26be16707f4a805d3303ab2531006e1:/docs/source/TreeLoader.html diff --git a/docs/source/TreeLoader.html b/docs/source/TreeLoader.html index 1b8d1561..0b98afb1 100644 --- a/docs/source/TreeLoader.html +++ b/docs/source/TreeLoader.html @@ -1,5 +1,6 @@
+
+nodeParameter: 'node',
paramOrder: ['param1','param2','param3']
-paramOrder: 'param1 param2 param3'
-paramOrder: 'param1,param2,param3'
-paramOrder: 'param1|param2|param'
+paramOrder: 'node param1 param2 param3'
+paramOrder: 'param1,node,param2,param3'
+paramOrder: 'param1|param2|param|node'
*/
paramOrder: undefined,
@@ -141,6 +142,12 @@ paramOrder: 'param1|param2|param'
*/
paramsAsHash: false,
+ /**
+ * @cfg {String} nodeParameter The name of the parameter sent to the server which contains
+ * the identifier of the node. Defaults to 'node'.
+ */
+ nodeParameter: 'node',
+
/**
* @cfg {Function} directFn
* Function to call when executing a request.
@@ -152,8 +159,10 @@ paramOrder: 'param1|param2|param'
* This is called automatically when a node is expanded, but may be used to reload
* a node (or append new children if the {@link #clearOnLoad} option is false.)
* @param {Ext.tree.TreeNode} node
- * @param {Function} callback
- * @param (Object) scope
+ * @param {Function} callback Function to call after the node has been loaded. The
+ * function is passed the TreeNode which was requested to be loaded.
+ * @param (Object) scope The cope (this
reference) in which the callback is executed.
+ * defaults to the loaded TreeNode.
*/
load : function(node, callback, scope){
if(this.clearOnLoad){
@@ -162,7 +171,7 @@ paramOrder: 'param1|param2|param'
}
}
if(this.doPreload(node)){ // preloaded json children
- this.runCallback(callback, scope || node, []);
+ this.runCallback(callback, scope || node, [node]);
}else if(this.directFn || this.dataUrl || this.url){
this.requestData(node, callback, scope || node);
}
@@ -187,27 +196,29 @@ paramOrder: 'param1|param2|param'
},
getParams: function(node){
- var buf = [], bp = this.baseParams;
+ var bp = Ext.apply({}, this.baseParams),
+ np = this.nodeParameter,
+ po = this.paramOrder;
+
+ np && (bp[ np ] = node.id);
+
if(this.directFn){
- buf.push(node.id);
- if(bp){
- if(this.paramOrder){
- for(var i = 0, len = this.paramOrder.length; i < len; i++){
- buf.push(bp[this.paramOrder[i]]);
- }
- }else if(this.paramsAsHash){
- buf.push(bp);
+ var buf = [node.id];
+ if(po){
+ // reset 'buf' if the nodeParameter was included in paramOrder
+ if(np && po.indexOf(np) > -1){
+ buf = [];
}
+
+ for(var i = 0, len = po.length; i < len; i++){
+ buf.push(bp[ po[i] ]);
+ }
+ }else if(this.paramsAsHash){
+ buf = [bp];
}
return buf;
}else{
- for(var key in bp){
- if(!Ext.isFunction(bp[key])){
- buf.push(encodeURIComponent(key), "=", encodeURIComponent(bp[key]), "&");
- }
- }
- buf.push("node=", encodeURIComponent(node.id));
- return buf.join("");
+ return bp;
}
},
@@ -272,7 +283,7 @@ paramOrder: 'param1|param2|param'
* Example:
new Ext.tree.TreePanel({
...
- new Ext.tree.TreeLoader({
+ loader: new Ext.tree.TreeLoader({
url: 'dataUrl',
createNode: function(attr) {
// Allow consolidation consignments to have
@@ -281,7 +292,7 @@ new Ext.tree.TreePanel({
attr.iconCls = 'x-consol',
attr.allowDrop = true;
}
- return Ext.tree.TreeLoader.prototype.call(this, attr);
+ return Ext.tree.TreeLoader.prototype.createNode.call(this, attr);
}
}),
...
@@ -294,10 +305,10 @@ new Ext.tree.TreePanel({
if(this.baseAttrs){
Ext.applyIf(attr, this.baseAttrs);
}
- if(this.applyLoader !== false){
+ if(this.applyLoader !== false && !attr.loader){
attr.loader = this;
}
- if(typeof attr.uiProvider == 'string'){
+ if(Ext.isString(attr.uiProvider)){
attr.uiProvider = this.uiProviders[attr.uiProvider] || eval(attr.uiProvider);
}
if(attr.nodeType){
@@ -339,6 +350,11 @@ new Ext.tree.TreePanel({
var a = response.argument;
this.fireEvent("loadexception", this, a.node, response);
this.runCallback(a.callback, a.scope || a.node, [a.node]);
+ },
+
+ destroy : function(){
+ this.abort();
+ this.purgeListeners();
}
});