AJAX式多数据源及节点异步加载树_meetrice

简介: 预览:demo.html: treeloader.js:/**//** * @include "js/Ext.ux.MyTreeLoader/ColumnNodeUI.js" * @include "js/Ext.

预览:
img_69b687855724990673b57b395e94a579.jpg
demo.html:

img_a6339ee3e57d1d52bc7d02b338e15a60.gif < script  type ="text/javascript"  src ="js/Ext.ux.MyTreeLoader/MyTreeLoader.js" ></ script >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< script  type ="text/javascript"  src ="treeloader.js" ></ script >
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
< div  id ="tree-ct" ></ div >

treeloader.js:

img_405b18b4b6584ae338e0f6ecaf736533.gif img_1c53668bcee393edac0d7b3b3daff1ae.gif /**/ /**
img_33d02437d135341f0800e3d415312ae8.gif * @include "js/Ext.ux.MyTreeLoader/ColumnNodeUI.js"
img_33d02437d135341f0800e3d415312ae8.gif * @include "js/Ext.ux.MyTreeLoader/MyTreeLoader.js"
img_33d02437d135341f0800e3d415312ae8.gif * @include "js/Ext.ux.MyTreeLoader/TreeNodeProvider.js"
img_05dd8d549cff04457a6366b0a7c9352a.gif 
*/

img_a6339ee3e57d1d52bc7d02b338e15a60.gifExt.BLANK_IMAGE_URL 
=   ' js/ext-2.0/resources/images/default/s.gif ' ;
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
var  flag  =   true ; //  To toggle the refresh
img_a6339ee3e57d1d52bc7d02b338e15a60.gif

img_405b18b4b6584ae338e0f6ecaf736533.gifimg_1c53668bcee393edac0d7b3b3daff1ae.gifExt.onReady(
function ()  img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif {
img_33d02437d135341f0800e3d415312ae8.gif
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif    
var treeNodeProvider = img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif        data : [],
// Property in which are set the data to elaborate
img_33d02437d135341f0800e3d415312ae8.gif
        dataUrl : 'addressBook.do?dispatch=queryAddressBook',
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif        getNodes : 
function() img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif// Here you process your data
img_33d02437d135341f0800e3d415312ae8.gif
            return Ext.decode(this.data);
img_105a1e124122b2abcee4ea8e9f5108f3.gif        }
,
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif        setData : 
function(data) img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{// Called internally by
img_33d02437d135341f0800e3d415312ae8.gif
            // Ext.tree.MyTreeLoader by the method
img_33d02437d135341f0800e3d415312ae8.gif
            // updateTreeNodeProvider
img_33d02437d135341f0800e3d415312ae8.gif
            this.data = data;
img_105a1e124122b2abcee4ea8e9f5108f3.gif        }
,
img_33d02437d135341f0800e3d415312ae8.gif        scope : 
this
img_33d02437d135341f0800e3d415312ae8.gif            
// Could be useful to use when you elaborates data to switch the
img_33d02437d135341f0800e3d415312ae8.gif
            // contextimg_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gifnot used in this example and it's not required
img_105a1e124122b2abcee4ea8e9f5108f3.gif
    }
;
img_33d02437d135341f0800e3d415312ae8.gif
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif    
var treeNodeProvider2 = img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif        data : [],
// Property in which are set the data to elaborate
img_33d02437d135341f0800e3d415312ae8.gif
        dataUrl : 'companyGroup.do?dispatch=queryGroup',
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif        getNodes : 
function() img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif// Here you process your data
img_33d02437d135341f0800e3d415312ae8.gif
            return Ext.decode(this.data);
img_105a1e124122b2abcee4ea8e9f5108f3.gif        }
,
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif        setData : 
function(data) img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{// Called internally by
img_33d02437d135341f0800e3d415312ae8.gif
            // Ext.tree.MyTreeLoader by the method
img_33d02437d135341f0800e3d415312ae8.gif
            // updateTreeNodeProvider
img_33d02437d135341f0800e3d415312ae8.gif
            this.data = data;
img_105a1e124122b2abcee4ea8e9f5108f3.gif        }
,
img_33d02437d135341f0800e3d415312ae8.gif        scope : 
this
img_33d02437d135341f0800e3d415312ae8.gif            
// Could be useful to use when you elaborates data to switch the
img_33d02437d135341f0800e3d415312ae8.gif
            // contextimg_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gifnot used in this example and it's not required
img_105a1e124122b2abcee4ea8e9f5108f3.gif
    }
;
img_33d02437d135341f0800e3d415312ae8.gif
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif    
var myTreeLoader = new Ext.tree.MyTreeLoader(img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif        treeNodeProvider : treeNodeProvider
img_105a1e124122b2abcee4ea8e9f5108f3.gif    }
);
img_33d02437d135341f0800e3d415312ae8.gif
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif    
var myTreeLoader2 = new Ext.tree.MyTreeLoader(img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif        treeNodeProvider : treeNodeProvider2
img_105a1e124122b2abcee4ea8e9f5108f3.gif    }
);
img_33d02437d135341f0800e3d415312ae8.gif
img_33d02437d135341f0800e3d415312ae8.gif    myTreeLoader.updateTreeNodeProvider(myTreeLoader);
// if you want to
img_33d02437d135341f0800e3d415312ae8.gif
    // "preload"
img_33d02437d135341f0800e3d415312ae8.gif
    // the TreePanel with this
img_33d02437d135341f0800e3d415312ae8.gif
    // data
img_33d02437d135341f0800e3d415312ae8.gif

img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif    
var ajaxCallGetDataForTree = function(inputParameters) img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif        treePanel.body.mask(
"Loading dataimg_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif");
img_33d02437d135341f0800e3d415312ae8.gif        setTimeout(ajaxCallbackGetDataForTree, 
1000);
img_105a1e124122b2abcee4ea8e9f5108f3.gif    }

img_33d02437d135341f0800e3d415312ae8.gif
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif    
var ajaxCallbackGetDataForTree = function() img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif
img_33d02437d135341f0800e3d415312ae8.gif        treePanel.body.unmask();
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif        treePanel.body.highlight(
'#c3daf9'img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif            block : 
true
img_105a1e124122b2abcee4ea8e9f5108f3.gif        }
);
img_33d02437d135341f0800e3d415312ae8.gif        
// Simulating that I have received the response that is treeData2 from
img_33d02437d135341f0800e3d415312ae8.gif
        // the callback of the ajaxCall
img_33d02437d135341f0800e3d415312ae8.gif
        var rootNode = treePanel.getRootNode();// get the rootnode
img_33d02437d135341f0800e3d415312ae8.gif
        var loader = treePanel.getLoader();// Get the loader, note that is of
img_33d02437d135341f0800e3d415312ae8.gif
        // type MyTreeLoader
img_33d02437d135341f0800e3d415312ae8.gif
        loader.updateTreeNodeProvider(myTreeLoader);
img_33d02437d135341f0800e3d415312ae8.gif        loader.load(rootNode);
img_105a1e124122b2abcee4ea8e9f5108f3.gif    }

img_33d02437d135341f0800e3d415312ae8.gif
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif    
var ajaxCallGetDataForTree2 = function(inputParameters) img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif        treePanel.body.mask(
"Loading dataimg_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif");
img_33d02437d135341f0800e3d415312ae8.gif        setTimeout(ajaxCallbackGetDataForTree2, 
1000);
img_105a1e124122b2abcee4ea8e9f5108f3.gif    }

img_33d02437d135341f0800e3d415312ae8.gif
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif    
var ajaxCallbackGetDataForTree2 = function() img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif
img_33d02437d135341f0800e3d415312ae8.gif        treePanel.body.unmask();
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif        treePanel.body.highlight(
'#c3daf9'img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif            block : 
true
img_105a1e124122b2abcee4ea8e9f5108f3.gif        }
);
img_33d02437d135341f0800e3d415312ae8.gif        
// Simulating that I have received the response that is treeData2 from
img_33d02437d135341f0800e3d415312ae8.gif
        // the callback of the ajaxCall
img_33d02437d135341f0800e3d415312ae8.gif
        var rootNode = treePanel.getRootNode();// get the rootnode
img_33d02437d135341f0800e3d415312ae8.gif
        var loader = treePanel.getLoader();// Get the loader, note that is of
img_33d02437d135341f0800e3d415312ae8.gif
        // type MyTreeLoader
img_33d02437d135341f0800e3d415312ae8.gif
        loader.updateTreeNodeProvider(myTreeLoader2);
img_33d02437d135341f0800e3d415312ae8.gif        loader.load(rootNode);
img_33d02437d135341f0800e3d415312ae8.gif
img_105a1e124122b2abcee4ea8e9f5108f3.gif    }

img_33d02437d135341f0800e3d415312ae8.gif
img_33d02437d135341f0800e3d415312ae8.gif    
var flag = true;
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif    
var basePanelCfg = img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif        title : 
"AJAX式多数据源及节点异步加载",
img_33d02437d135341f0800e3d415312ae8.gif        preloadChildren : 
true,
img_33d02437d135341f0800e3d415312ae8.gif        lines : 
false,
img_33d02437d135341f0800e3d415312ae8.gif        clearOnLoad : 
true,
img_33d02437d135341f0800e3d415312ae8.gif        rootVisible : 
false,
img_33d02437d135341f0800e3d415312ae8.gif        containerScroll : 
true,
img_33d02437d135341f0800e3d415312ae8.gif        frame : 
false,
img_33d02437d135341f0800e3d415312ae8.gif        collapsible : 
false,
img_33d02437d135341f0800e3d415312ae8.gif        animate : 
true,
img_33d02437d135341f0800e3d415312ae8.gif        loader : myTreeLoader,
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif        tbar : [
img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif            text : 
"加载通讯录",
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif            handler : 
function() img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif                
// Simulating change the treeNodeProvider of the loader
img_33d02437d135341f0800e3d415312ae8.gif
                var rootNode = treePanel.getRootNode();// get the rootnode
img_33d02437d135341f0800e3d415312ae8.gif
                var loader = treePanel.getLoader();// Get the loader, note that
img_33d02437d135341f0800e3d415312ae8.gif
                // is of type MyTreeLoader
img_33d02437d135341f0800e3d415312ae8.gif
                loader.setTreeNodeProvider(treeNodeProvider);
img_33d02437d135341f0800e3d415312ae8.gif                
// Simulating an ajax call
img_33d02437d135341f0800e3d415312ae8.gif
                ajaxCallGetDataForTree();
img_105a1e124122b2abcee4ea8e9f5108f3.gif            }

img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif        }
img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif            text : 
"加载组织",
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif            handler : 
function() img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif                
// Simulating change the treeNodeProvider2 of the loader
img_33d02437d135341f0800e3d415312ae8.gif
                var rootNode = treePanel.getRootNode();// get the rootnode
img_33d02437d135341f0800e3d415312ae8.gif
                var loader = treePanel.getLoader();// Get the loader, note that
img_33d02437d135341f0800e3d415312ae8.gif
                // is of type MyTreeLoader
img_33d02437d135341f0800e3d415312ae8.gif
                loader.setTreeNodeProvider(treeNodeProvider2);
img_33d02437d135341f0800e3d415312ae8.gif                
// Simulating a different ajax call
img_33d02437d135341f0800e3d415312ae8.gif
                ajaxCallGetDataForTree2();
img_105a1e124122b2abcee4ea8e9f5108f3.gif            }

img_105a1e124122b2abcee4ea8e9f5108f3.gif        }
]
img_105a1e124122b2abcee4ea8e9f5108f3.gif    }
;
img_33d02437d135341f0800e3d415312ae8.gif
img_33d02437d135341f0800e3d415312ae8.gif    
var treePanel = new Ext.tree.TreePanel(basePanelCfg);
img_33d02437d135341f0800e3d415312ae8.gif
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif    
var root = new Ext.tree.AsyncTreeNode(img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif        text : 
'Root',
img_33d02437d135341f0800e3d415312ae8.gif        draggable : 
false,
img_33d02437d135341f0800e3d415312ae8.gif        id : 
'1'
img_105a1e124122b2abcee4ea8e9f5108f3.gif    }
);
img_33d02437d135341f0800e3d415312ae8.gif
img_33d02437d135341f0800e3d415312ae8.gif    treePanel.setRootNode(root);
img_33d02437d135341f0800e3d415312ae8.gif    treePanel.render(
'tree-ct');
img_05dd8d549cff04457a6366b0a7c9352a.gif}
);
img_a6339ee3e57d1d52bc7d02b338e15a60.gif

js/Ext.ux.MyTreeLoader/MyTreeLoader.js:

img_405b18b4b6584ae338e0f6ecaf736533.gif img_1c53668bcee393edac0d7b3b3daff1ae.gif /**/ /*
img_33d02437d135341f0800e3d415312ae8.gif * Version 0.2.3
img_33d02437d135341f0800e3d415312ae8.gif * 
img_33d02437d135341f0800e3d415312ae8.gif * Ext.tree.MyTreeLoader
img_33d02437d135341f0800e3d415312ae8.gif * 
img_33d02437d135341f0800e3d415312ae8.gif * @author Dott. Ing. Marco Bellocchi @date 24. April 2008 @license
img_33d02437d135341f0800e3d415312ae8.gif * Ext.tree.MyTreeLoader.js is licensed under the terms of the Open Source LGPL
img_33d02437d135341f0800e3d415312ae8.gif * 3.0 license.
img_33d02437d135341f0800e3d415312ae8.gif * 
img_33d02437d135341f0800e3d415312ae8.gif * @include "js/Ext.ux.MyTreeLoader/ColumnNodeUI.js" @include
img_33d02437d135341f0800e3d415312ae8.gif * "js/Ext.ux.MyTreeLoader/MyTreeLoader.js" @include
img_33d02437d135341f0800e3d415312ae8.gif * "js/Ext.ux.MyTreeLoader/TreeNodeProvider.js"
img_33d02437d135341f0800e3d415312ae8.gif * 
img_33d02437d135341f0800e3d415312ae8.gif * License details: http://www.gnu.org/licenses/lgpl.html
img_05dd8d549cff04457a6366b0a7c9352a.gif 
*/

img_a6339ee3e57d1d52bc7d02b338e15a60.gif
img_405b18b4b6584ae338e0f6ecaf736533.gifimg_1c53668bcee393edac0d7b3b3daff1ae.gifExt.tree.MyTreeLoader 
=   function (config)  img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif {
img_33d02437d135341f0800e3d415312ae8.gif    
// @private
img_33d02437d135341f0800e3d415312ae8.gif
    var canFireLoadEvent = true;// private
img_33d02437d135341f0800e3d415312ae8.gif
    // @private
img_33d02437d135341f0800e3d415312ae8.gif
    var treeNodeProvider = null;
img_33d02437d135341f0800e3d415312ae8.gif    
// @private
img_33d02437d135341f0800e3d415312ae8.gif
    var loading = false;
img_33d02437d135341f0800e3d415312ae8.gif
img_33d02437d135341f0800e3d415312ae8.gif    Ext.apply(
this, config);
img_33d02437d135341f0800e3d415312ae8.gif    Ext.tree.MyTreeLoader.superclass.constructor.call(
this, config);
img_33d02437d135341f0800e3d415312ae8.gif    
// TO FIX I need to do that for retro compatibility, but you MUST use
img_33d02437d135341f0800e3d415312ae8.gif
    // getTreeNodeProvider to have access to it!
img_33d02437d135341f0800e3d415312ae8.gif
    treeNodeProvider = this.treeNodeProvider;
img_33d02437d135341f0800e3d415312ae8.gif    
// dataUrl = this.dataUrl;
img_33d02437d135341f0800e3d415312ae8.gif

img_33d02437d135341f0800e3d415312ae8.gif    
// @private
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
    var processResponse = function(o, node, callback) img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif        
try img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif            node.beginUpdate();
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif            
for (var i = 0, len = o.length; i < len; i++img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif                
var n = this.createNode(o[i]);
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif                
if (n) img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif                    node.appendChild(n);
img_105a1e124122b2abcee4ea8e9f5108f3.gif                }

img_105a1e124122b2abcee4ea8e9f5108f3.gif            }

img_33d02437d135341f0800e3d415312ae8.gif            node.endUpdate();
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif        }
 catch (e) img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif            canFireLoadEvent 
= false;
img_33d02437d135341f0800e3d415312ae8.gif            
this.fireEvent("loadexception"this, node, treeNodeProvider.data);
img_105a1e124122b2abcee4ea8e9f5108f3.gif        }

img_33d02437d135341f0800e3d415312ae8.gif        
// make sure we notify
img_33d02437d135341f0800e3d415312ae8.gif
        // the node that we finished
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
        if (typeof callback == "function"img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif            callback();
img_105a1e124122b2abcee4ea8e9f5108f3.gif        }

img_33d02437d135341f0800e3d415312ae8.gif        
if (canFireLoadEvent === true)
img_33d02437d135341f0800e3d415312ae8.gif            
this.fireEvent("load"this, node, treeNodeProvider.data);// Passing
img_105a1e124122b2abcee4ea8e9f5108f3.gif
    }
.createDelegate(this);
img_33d02437d135341f0800e3d415312ae8.gif
img_33d02437d135341f0800e3d415312ae8.gif    
// @private
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
    var requestData = function(node, callback) img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif        
if (this.fireEvent("beforeload"this, node, callback) !== falseimg_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif            
this.transId = Ext.Ajax.request(img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif                method : 
this.requestMethod,
img_33d02437d135341f0800e3d415312ae8.gif                url : treeNodeProvider.dataUrl 
|| treeNodeProvider.url,
img_33d02437d135341f0800e3d415312ae8.gif                
// success: this.handleResponse,
img_33d02437d135341f0800e3d415312ae8.gif
                success : handleResponse,
img_33d02437d135341f0800e3d415312ae8.gif                failure : 
this.fireEvent("loadexception"this, node,
img_33d02437d135341f0800e3d415312ae8.gif                        treeNodeProvider.data),
img_33d02437d135341f0800e3d415312ae8.gif                scope : 
this,
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif                argument : 
img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif                    callback : callback,
img_33d02437d135341f0800e3d415312ae8.gif                    node : node
img_105a1e124122b2abcee4ea8e9f5108f3.gif                }
,
img_33d02437d135341f0800e3d415312ae8.gif                params : 
this.getParams(node)
img_105a1e124122b2abcee4ea8e9f5108f3.gif            }
);
img_33d02437d135341f0800e3d415312ae8.gif
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif        }
 else img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif            canFireLoadEvent 
= false;
img_105a1e124122b2abcee4ea8e9f5108f3.gif        }

img_105a1e124122b2abcee4ea8e9f5108f3.gif    }
.createDelegate(this);
img_33d02437d135341f0800e3d415312ae8.gif
img_33d02437d135341f0800e3d415312ae8.gif    
// @private
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
    var handleResponse = function(response) img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif        
var a = response.argument;
img_33d02437d135341f0800e3d415312ae8.gif        
this.processResponse(response, a.node, a.callback);
img_33d02437d135341f0800e3d415312ae8.gif        
this.fireEvent("load"this, a.node, response);
img_105a1e124122b2abcee4ea8e9f5108f3.gif    }
.createDelegate(this);
img_33d02437d135341f0800e3d415312ae8.gif
img_33d02437d135341f0800e3d415312ae8.gif    
// @public
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
    this.load = function(node, callback) img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif        canFireLoadEvent 
= true;// Reset the flag
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
        if (this.clearOnLoad) img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif            
while (node.firstChild) img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif                
var tmpNode = node.firstChild;
img_33d02437d135341f0800e3d415312ae8.gif                node.removeChild(tmpNode);
img_33d02437d135341f0800e3d415312ae8.gif                tmpNode.destroy();
// Destroy actually cascades, see,
img_33d02437d135341f0800e3d415312ae8.gif
                // http://extjs.com/forum/showthread.php?t=14993
img_105a1e124122b2abcee4ea8e9f5108f3.gif
            }

img_105a1e124122b2abcee4ea8e9f5108f3.gif        }

img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif        
if (this.doPreload(node)) img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif// preloaded json children
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
            if (typeof callback == "function"img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif                callback();
img_105a1e124122b2abcee4ea8e9f5108f3.gif            }

img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif        }
 else if (treeNodeProvider) img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif            requestData(node, callback);
img_105a1e124122b2abcee4ea8e9f5108f3.gif        }

img_105a1e124122b2abcee4ea8e9f5108f3.gif    }

img_33d02437d135341f0800e3d415312ae8.gif
img_33d02437d135341f0800e3d415312ae8.gif    
// @public
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
    this.isLoading = function() img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif        
return loading;
img_105a1e124122b2abcee4ea8e9f5108f3.gif    }

img_33d02437d135341f0800e3d415312ae8.gif
img_33d02437d135341f0800e3d415312ae8.gif    
// @public
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
    this.updateTreeNodeProvider = function(obj) img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif        
if (treeNodeProvider) img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif            treeNodeProvider.setData(obj);
img_105a1e124122b2abcee4ea8e9f5108f3.gif        }

img_105a1e124122b2abcee4ea8e9f5108f3.gif    }

img_33d02437d135341f0800e3d415312ae8.gif
img_33d02437d135341f0800e3d415312ae8.gif    
// @public
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
    this.getTreeNodeProvider = function() img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif        
return treeNodeProvider;
img_105a1e124122b2abcee4ea8e9f5108f3.gif    }

img_33d02437d135341f0800e3d415312ae8.gif    
// Set a new treeNodeProvider
img_33d02437d135341f0800e3d415312ae8.gif
    // @public
img_2887d91d0594ef8793c1db92b8a1d545.gifimg_7a2b9a960ee9a98bfd25d306d55009f8.gif
    this.setTreeNodeProvider = function(newTreeNodeProvider) img_a76e9bb6ed00cf1c9c9f4ee2f04b558b.gif{
img_33d02437d135341f0800e3d415312ae8.gif        
if (newTreeNodeProvider == null
img_33d02437d135341f0800e3d415312ae8.gif                
|| (typeof newTreeNodeProvider == 'undefined'))
img_33d02437d135341f0800e3d415312ae8.gif            
throw 'setTreeNodeProvider, newTreeNodeProvider == null || (typeof newTreeNodeProvider == undefined)';
img_33d02437d135341f0800e3d415312ae8.gif        treeNodeProvider 
= newTreeNodeProvider;
img_105a1e124122b2abcee4ea8e9f5108f3.gif    }

img_33d02437d135341f0800e3d415312ae8.gif
img_05dd8d549cff04457a6366b0a7c9352a.gif}
;
img_a6339ee3e57d1d52bc7d02b338e15a60.gifExt.tree.MyTreeLoader 
=  Ext.extend(Ext.tree.MyTreeLoader, Ext.tree.TreeLoader);
img_a6339ee3e57d1d52bc7d02b338e15a60.gif
相关文章
|
8月前
|
前端开发 JavaScript Java
使用Ajax进行异步交互:提升Java Web应用的用户体验
【4月更文挑战第3天】Ajax技术在Web开发中提升UX,通过与服务器异步交互实现页面局部更新,无需完整刷新。核心组件包括XMLHttpRequest、JavaScript、HTML/CSS及服务器端脚本。在Java Web应用中,可使用原生JavaScript或框架如jQuery、AngularJS实现Ajax请求。Ajax减少页面刷新,实现实时数据更新,即时表单验证和动态UI,显著改善用户体验,是现代Web开发不可或缺的一部分。
103 0
|
8月前
|
前端开发 JavaScript API
Ajax技术的秘密揭秘:异步传输,高效交互
Ajax技术的秘密揭秘:异步传输,高效交互
|
5月前
|
前端开发 JavaScript Java
Ajax进行异步交互:提升Java Web应用的用户体验
Ajax 技术允许在不重载整个页面的情况下与服务器异步交换数据,通过局部更新页面内容,极大提升了 Java Web 应用的响应速度和用户体验。本文介绍 Ajax 的基本原理及其实现方式,包括使用 XMLHttpRequest 对象发送请求、处理响应数据,并在 Java Web 应用中集成 Ajax。此外,还探讨了 Ajax 如何通过减少页面刷新、实时数据更新等功能改善用户体验。
89 3
|
7月前
|
数据采集 Web App开发 前端开发
技术心得记录:如何用JAVA爬取AJAX加载后的页面(转载)
技术心得记录:如何用JAVA爬取AJAX加载后的页面(转载)
|
7月前
|
XML 移动开发 前端开发
JS设置Ajax为同步或异步
JS设置Ajax为同步或异步
106 0
|
8月前
|
XML JSON 前端开发
学习Ajax使用异步对象发送请求
Ajax,全称Asynchronous JavaScript and XML(异步JavaScript和XML),是一种用于创建更好、更快以及交互性更强的Web应用程序的技术。
84 3
|
7月前
1.ajax同步和异步区别 2.post和get区别
1.ajax同步和异步区别 2.post和get区别
38 0
|
8月前
|
JSON 前端开发 JavaScript
探秘 AJAX:让网页变得更智能的异步技术(下)
探秘 AJAX:让网页变得更智能的异步技术(下)
探秘 AJAX:让网页变得更智能的异步技术(下)
|
8月前
|
XML 前端开发 JavaScript
探秘 AJAX:让网页变得更智能的异步技术(上)
探秘 AJAX:让网页变得更智能的异步技术(上)
探秘 AJAX:让网页变得更智能的异步技术(上)
|
JSON 前端开发 数据格式
ztree+ajax+json请求,实现加载一棵ztree树
ztree+ajax+json请求,实现加载一棵ztree树
80 0
ztree+ajax+json请求,实现加载一棵ztree树