DWRTreeLoader.js
上传用户:zaktkj
上传日期:2022-08-08
资源大小:5770k
文件大小:2k
源码类别:

JavaScript

开发平台:

JavaScript

  1. Ext.tree.DWRTreeLoader = function(config) {
  2.     Ext.tree.DWRTreeLoader.superclass.constructor.call(this, config);
  3. };
  4. Ext.extend(Ext.tree.DWRTreeLoader, Ext.tree.TreeLoader, {
  5.     requestData : function(node, callback) {
  6.         if (this.fireEvent("beforeload", this, node, callback) !== false) {
  7.             //todo
  8.             //var params = this.getParams(node);
  9.             var callParams = new Array();
  10.             var success = this.handleResponse.createDelegate(this, [node, callback], 1);
  11.             var error = this.handleFailure.createDelegate(this, [node, callback], 1);
  12.             callParams.push(node.id);
  13.             callParams.push({callback:success, errorHandler:error});
  14.             //todo: do we need to set this to something else?
  15.             this.transId = true;
  16.             this.dataUrl.apply(this, callParams);
  17.         } else {
  18.             // if the load is cancelled, make sure we notify
  19.             // the node that we are done
  20.             if (typeof callback == "function") {
  21.                 // alert(callback);
  22.                 callback();
  23.             }
  24.         }
  25.     },
  26.     processResponse : function(response, node, callback){
  27.         try {
  28.             for(var i = 0; i < response.length; i++){
  29.                 var n = this.createNode(response[i]);
  30.                 if(n){
  31.                     node.appendChild(n);
  32.                 }
  33.             }
  34.             if(typeof callback == "function"){
  35.                 callback(this, node);
  36.             }
  37.         }catch(e){
  38.             this.handleFailure(response);
  39.         }
  40.     },
  41.     handleResponse : function(response, node, callback){
  42.         this.transId = false;
  43.         this.processResponse(response, node, callback);
  44.         this.fireEvent("load", this, node, response);
  45.     },
  46.     handleFailure : function(response, node, callback){
  47.         this.transId = false;
  48.         this.fireEvent("loadexception", this, node, response);
  49.         if(typeof callback == "function"){
  50.             callback(this, node);
  51.         }
  52.     }
  53. });