<script type="text/javascript" src="ext/XmlTreeLoader.js"></script>
<script type="text/javascript" src="xml-tree-loader.js"></script>
/**
* 动态加载本地xml格式的数据
*/
var mytree_4=new Ext.tree.TreePanel({
//el:"container",//应用到的html元素id
animate:true,//以动画形式伸展,收缩子节点
//title:"Extjs静态树",
//collapsible:true,
rootVisible:true,//是否显示根节点
autoScroll:true,
autoHeight:true,
//height:'100%',
width:'100%',
lines:true,//节点之间连接的横竖线
//树加载器(TreeLoader)的目的是从URL延迟加载树节点Ext.tree.TreeNode的子节点。返回值必须是以树格式的javascript数组
loader: new Ext.app.BookLoader({
//loader: new Ext.ux.tree.XmlTreeLoader({
preloadChildren: true,//若为true,则loader在节点第一次访问时加载"children"的属性
clearOnLoad: false,//(可选)默认为true。在读取数据前移除已存在的节点
dataUrl:'xml-tree-data.xml'
}),
root: new Ext.tree.AsyncTreeNode({text:"根目录"}),
collapseFirst:false,
//添加事件
listeners : {
//当点击时在右边主窗口中加载相应的资源
click : function(node, e){
alert(node.isLeaf());
e.stopEvent();//停止href属性产品的链接操作(自动)
if(node.isLeaf()){//如果是非叶子节点,则不用加载相应资源
loadPanel(node);//加载叶子节点对应的资源
}
}
}
});
xml-tree-loader.js文件
Ext.app.BookLoader = Ext.extend(Ext.ux.tree.XmlTreeLoader, {
processAttributes : function(attr){
//alert(attr.leaf + attr.text);
if(attr.class1){ // is it an author node?
//attr.leaf = false;
attr.text = attr.class1;
// Set the node text that will show in the tree since our raw data does not include a text attribute:
// attr.text = attr.first + ' ' + attr.last;
// Author icon, using the gender flag to choose a specific icon:
//attr.iconCls = 'author-' + attr.gender;
// Override these values for our folder nodes because we are loading all data at once. If we were
// loading each node asynchronously (the default) we would not want to do this:
attr.loaded = true;
attr.expanded = true;
} else if(attr.title){ // is it a book node?
// Set the node text that will show in the tree since our raw data does not include a text attribute:
attr.text = attr.title ;
// Book icon:
// attr.iconCls = 'book';
// Tell the tree this is a leaf node. This could also be passed as an attribute in the original XML,
// but this example demonstrates that you can control this even when you cannot dictate the format of
// the incoming source XML:
attr.leaf = true;
}
}
});
分享到:
相关推荐
该文件中包含了一些实例:如何加载数据到extjs
NULL 博文链接:https://maoyi606.iteye.com/blog/1782825
通过java 访问数据库而生成节点 子节点的 ID 与 父节点的关系为“父节点id_子节点id”此id为数据库中的id 同理“父节点id_子节点id_子子节点id”,因此加载树时将node.id做为参数 通过split("_"),根据数据的长度就...
ExtJs中Store加载(load)时候提示信息
此压缩包中完全能实现的功能是在extjs中让本地照片预览,并且将地址传递给java后台,将图片文件以blob的形式存储到oracle数据库,并且可以默认将数据库中的数据第一次加载在预览框里(也就是从数据库中读出blob数据...
NULL 博文链接:https://firezhfox.iteye.com/blog/1885329
基于ExtJS的Web XML编辑器设计与实现,赵丽娟,温巧燕,XML文件的编辑只能通过桌面应用程序实现,这使得B/S 模式的系统编辑XML文件的过程变得繁琐。即使页面提供文本框控件供用户编辑XML文��
此压缩包中完全能实现的功能是在extjs中让本地照片预览,并且将地址传递给java后台,将图片文件以blob的形式存储到oracle数据库,并且可以默认将数据库中的数据第一次加载在预览框里(也就是从数据库中读出blob数据...
extjs动态树struts请求数据json数据格式
Extjs动态菜单可添加子项和编辑子项,拖动保存、dwr实现存储数据。
extjs读取解析后端json格式数据并显示条形图,非常好看的特效,只能用炫酷来形容,感兴趣就下载看看吧,用在自己的网站觉得吸引眼球!
AJAX: 以JSON数据格式,使用ExtJS构造动态异步加载的树。
EXTJS_DATEFORMAT 日期格式对应,网上找到的,挺好用的
php+extjs+grid实时显示更新数据
NULL 博文链接:https://bernoulli.iteye.com/blog/1885567
终于找到了 EXTJS Javascript HTML 代码格式化 工具。
使用ExtJs获取后台json格式的数据必须的七个jar包,commons-beanuti-1s-1.7.0.jar,commons-collections-3.1.jar,commons-lang-2.5.jar,commons-logging-1.0.4.jar,ezmorph-1.0.4.jar,json-lib-2.1.jar,...
在使用使用FormPanel时我们通常需要使用它的form对象来加载数据或提交数据。FormPanel中的 form对象为Ext.form.BasicForm类型的对象,它有load和submit方法分别用于加载数据和提交数据。而这两个方法都是通过调用 ...
NULL 博文链接:https://lusam06.iteye.com/blog/1826238
extjs tree 异步加载树型完整的一个web工程,自已已经试过,可用。