日期:2014-05-16 浏览次数:20314 次
<script language="JavaScript" type="text/javascript"> <!-- Ext.BLANK_IMAGE_URL = '../resources/ext/resources/images/default/s.gif'; Ext.onReady(function() { var ddTree = new Ext.tree.TreePanel({ el: 'ddTree', useArrows: true, enableDD: true, width: 200, height: 300, loader: new Ext.tree.TreeLoader({ dataUrl: "xxx.ashx" }), rootVisible: false, root: new Ext.tree.AsyncTreeNode({}), listeners: { 'beforeload': beforeloadHandler, 'load': loadHandler } }); ddTree.render(); ddTree.expandAll(); // 展开所有结点 var loading = null; function beforeloadHandler() { // 加载前事件响应处理 loading = new Ext.LoadMask(Ext.get(ddTree.getEl()), { msg: "请等待" }); loading.show(); } function loadHandler() { // 加载后事件响应处理 loading.hide(); } }); --> </script>
<script language="JavaScript" type="text/javascript"> <!-- Ext.BLANK_IMAGE_URL = '../js/ext/images/default/s.gif'; Ext.onReady(function() { var forumTree = new Ext.tree.TreePanel( { el: 'forumtree', useArrows: true, enableDD: true, width: 200, height: 300, rootVisible: false, root: new Ext.tree.AsyncTreeNode({}) }); forumTree.render(); // 加载提示 var loading = null; function showLoading() { loading = new Ext.LoadMask(Ext.get(forumTree.getEl()), { msg: "请等待" }); loading.show(); } function hideLoading() { loading.hide(); } showLoading(); // 由于使用TreeLoader在IE下无法正常加载数据,所以使用Ajax先获取数据再填充数据到root node下 Ext.Ajax.request({ url: 'xxx.ashx', success: function(request) { var data = Ext.util.JSON.decode(request.responseText); forumTree.getRootNode().appendChild(data); forumTree.getRootNode().expandChildNodes(true); hideLoading(); }, failure: function() { hideLoading(); Ext.MessageBox.show({ title: '版块管理', msg: '对不起,加载数据出现异常,请重试!', buttons: Ext.MessageBox.OK, icon: Ext.MessageBox.ERROR }); } }); }); --> </script>
function removeChildNodes(node) { while(node.firstChild) { removeChildNodes(node.firstChild);