combotree的加载方法
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ComboTree - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="http://www.zi-han.net/case/easyui/jquery-easyui-1.3.1/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="http://www.zi-han.net/case/easyui/jquery-easyui-1.3.1/themes/icon.css">
<link rel="stylesheet" type="text/css" href="http://www.zi-han.net/case/easyui/jquery-easyui-1.3.1/demo/demo.css">
<script type="text/javascript" src="http://www.zi-han.net/case/easyui/jquery-easyui-1.3.1/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="http://www.zi-han.net/case/easyui/jquery-easyui-1.3.1/jquery.easyui.min.js"></script>
<script>
$.fn.tree.defaults.loadFilter = function (data, parent) {
var opt = $(this).data().tree.options;
var idField, textField, parentField;
if (opt.parentField) {
idField = opt.idField || 'id';
textField = opt.textField || 'text';
parentField = opt.parentField;
var i, l, treeData = [], tmpMap = [];
for (i = 0, l = data.length; i < l; i++) {
tmpMap[data[i][idField]] = data[i];
}
for (i = 0, l = data.length; i < l; i++) {
if (tmpMap[data[i][parentField]] && data[i][idField] != data[i][parentField]) {
if (!tmpMap[data[i][parentField]]['children'])
tmpMap[data[i][parentField]]['children'] = [];
data[i]['text'] = data[i][textField];
tmpMap[data[i][parentField]]['children'].push(data[i]);
} else {
data[i]['text'] = data[i][textField];
treeData.push(data[i]);
}
}
return treeData;
}
return data;
};
$.fn.combotree.defaults.loadFilter = $.fn.tree.defaults.loadFilter;
$(function(){
var jsonstr="[{'uid':null,'pageUtil':null,'id':1,'createDate':1415779364000,'modifyDate':1458544814000,'code':'Y001','name':'衣服','sortNo':0,'pid':0,'del':false,'note':'2','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':2,'createDate':1415779377000,'modifyDate':1415779377000,'code':'K001','name':'裤子','sortNo':0,'pid':0,'del':false,'note':'','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':3,'createDate':1415779390000,'modifyDate':1465981587000,'code':'Y0011','name':'袜子','sortNo':0,'pid':83,'del':false,'note':'','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':4,'createDate':1415779418000,'modifyDate':1420352406000,'code':'Y0022','name':'袄子塔顶','sortNo':0,'pid':83,'del':false,'note':'','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':5,'createDate':1415779429000,'modifyDate':1415779429000,'code':'Y0033','name':'运动衣','sortNo':0,'pid':83,'del':false,'note':'','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':6,'createDate':1415779455000,'modifyDate':1421036172000,'code':'FADSFDSAFADSFDASFADSFADS','name':'运动鞋FASDFADSFADSFADSFADS','sortNo':0,'pid':0,'del':false,'note':'FADSFADSFADSFADSFADSFDAS','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':7,'createDate':1415779513000,'modifyDate':1415779513000,'code':'ERKE','name':'品牌','sortNo':0,'pid':89,'del':false,'note':'','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':97,'createDate':1416411552000,'modifyDate':1419414704000,'code':'KGCZ','name':'开关插座','sortNo':0,'pid':0,'del':false,'note':'','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':98,'createDate':1416411574000,'modifyDate':1416411574000,'code':'KGCZ01','name':'86型','sortNo':0,'pid':8,'del':false,'note':'','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':99,'createDate':1416411593000,'modifyDate':1419399630000,'code':'KGCZ02','name':'118型','sortNo':0,'pid':8,'del':false,'note':'','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':100,'createDate':1416411975000,'modifyDate':1416411975000,'code':'DLQ','name':'断路器','sortNo':0,'pid':0,'del':false,'note':'','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':105,'createDate':1419236882000,'modifyDate':1419236882000,'code':'01','name':'电器','sortNo':0,'pid':0,'del':false,'note':'105','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':106,'createDate':1419236940000,'modifyDate':1419236940000,'code':'0101','name':'空调','sortNo':0,'pid':105,'del':false,'note':'106','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':107,'createDate':1419236954000,'modifyDate':1419236954000,'code':'0102','name':'冰箱','sortNo':0,'pid':105,'del':false,'note':'','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':110,'createDate':1419237269000,'modifyDate':1419237269000,'code':'0101','name':'手机','sortNo':0,'pid':105,'del':false,'note':'','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':111,'createDate':1419237294000,'modifyDate':1419237294000,'code':'010102','name':'触摸屏','sortNo':0,'pid':110,'del':false,'note':'','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':112,'createDate':1419237353000,'modifyDate':1419237353000,'code':'01','name':'电器','sortNo':0,'pid':0,'del':false,'note':'','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':115,'createDate':1419237560000,'modifyDate':1419402451000,'code':'0123','name':'电器123','sortNo':0,'pid':0,'del':false,'note':'21','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':116,'createDate':1419237574000,'modifyDate':1419237574000,'code':'0101','name':'3c','sortNo':0,'pid':105,'del':false,'note':'','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':117,'createDate':1419237585000,'modifyDate':1419237585000,'code':'010101','name':'手机','sortNo':0,'pid':116,'del':false,'note':'','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':168,'createDate':1419404597000,'modifyDate':1419404597000,'code':'ASZASZX','name':'ASDSAZX','sortNo':0,'pid':98,'del':false,'note':'XZC','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':176,'createDate':1422414566000,'modifyDate':1422414566000,'code':'1111','name':'111','sortNo':0,'pid':6,'del':false,'note':'11111','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':198,'createDate':1436841555000,'modifyDate':1437446373000,'code':'05000076','name':'猫爪鞋','sortNo':0,'pid':0,'del':false,'note':'丹诗戈','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':203,'createDate':1437533651000,'modifyDate':1437533651000,'code':'11000016','name':'舞蹈鞋','sortNo':0,'pid':0,'del':false,'note':'三沙','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':204,'createDate':1437534200000,'modifyDate':1437534200000,'code':'11000088','name':'足尖鞋','sortNo':0,'pid':0,'del':false,'note':'三沙','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':205,'createDate':1437534813000,'modifyDate':1437534813000,'code':'05000137','name':'连体服','sortNo':0,'pid':0,'del':false,'note':'丹诗戈','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':206,'createDate':1438167068000,'modifyDate':1438582999000,'code':'20','name':'服装','sortNo':0,'pid':1,'del':false,'note':'必迈','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':207,'createDate':1438582798000,'modifyDate':1438582798000,'code':'10','name':'鞋','sortNo':0,'pid':0,'del':false,'note':'必迈','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':208,'createDate':1438583023000,'modifyDate':1438583023000,'code':'30','name':'器配','sortNo':0,'pid':0,'del':false,'note':'必迈','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':209,'createDate':1442805522000,'modifyDate':1442805522000,'code':'11','name':'11','sortNo':0,'pid':5,'del':false,'note':'11','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':210,'createDate':1442807735000,'modifyDate':1442807735000,'code':'ww','name':'ww','sortNo':0,'pid':206,'del':false,'note':'ww','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':211,'createDate':1442975848000,'modifyDate':1442975848000,'code':'02','name':'电视','sortNo':0,'pid':105,'del':false,'note':'02','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':212,'createDate':1442975923000,'modifyDate':1442975923000,'code':'02012','name':'液晶电视','sortNo':0,'pid':211,'del':false,'note':'液晶电视','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':213,'createDate':1442997714000,'modifyDate':1442997816000,'code':'d002','name':'短裤','sortNo':0,'pid':2,'del':false,'note':'ddd','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':214,'createDate':1442997854000,'modifyDate':1442997854000,'code':'m001','name':'毛衣','sortNo':0,'pid':206,'del':false,'note':'mm','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':215,'createDate':1445411610000,'modifyDate':1445411610000,'code':'cj','name':'厨具','sortNo':0,'pid':0,'del':false,'note':'','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':216,'createDate':1445954594000,'modifyDate':1445954594000,'code':'C','name':'上衣','sortNo':0,'pid':0,'del':false,'note':null,'_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':217,'createDate':1445954594000,'modifyDate':1445954594000,'code':'B','name':'短裙','sortNo':0,'pid':0,'del':false,'note':null,'_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':218,'createDate':1467710253000,'modifyDate':1467710253000,'code':'333333333','name':'11111111','sortNo':0,'pid':0,'del':false,'note':'3333333333','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':219,'createDate':1467710909000,'modifyDate':1467710909000,'code':'111','name':'按时发大厦的法定是','sortNo':0,'pid':211,'del':false,'note':'111','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':220,'createDate':1467712667000,'modifyDate':1467712667000,'code':'3333','name':'33333','sortNo':0,'pid':5,'del':false,'note':'3333','_parentId':0,'state':null,'children':null,'parent':false},{'uid':null,'pageUtil':null,'id':221,'createDate':1467712764000,'modifyDate':1467712764000,'code':'11111','name':'111111','sortNo':0,'pid':220,'del':false,'note':'111111','_parentId':0,'state':null,'children':null,'parent':false}]";
var json=eval('(' + jsonstr + ')');
$("#cc").combotree({
idField: 'id',
textField: 'name',
required: false,
parentField: 'pid',
data:json
});
});
</script>
<style>
*{
font-size:12px;
}
body {
font-family:helvetica,tahoma,verdana,sans-serif;
padding:20px;
font-size:13px;
margin:0;
}
h2 {
font-size:18px;
color:#333;
font-weight:bold;
margin:0;
margin-bottom:15px;
}
.demo-info{
background:#FFFEE6;
color:#8F5700;
padding:12px;
}
.demo-tip{
width:24px;
height:16px;
float:left;
}
</style>
</head>
<body>
<input id="cc" name="cc" style="width:200px;">
</body>
</html>
combotree的加载方法的更多相关文章
- xib文件的加载方法
xib文件的加载方法 以UITableViewCell的cell为例 很多时候因为系统的cell无法满足我们的日常需求,我们都会自定义cell 因为cell的界面比较固定,所以通常都会选择用xib来描 ...
- LIB库加载方法-引用百度百科
LIB库加载方法,有三种,如下: 1.LIB文件直接加入到工程文件列表中 在VC中打开File View一页,选中工程名,单击鼠标右键,然后选中\"Add Files to Project\ ...
- jquery ajax局部加载方法介绍
[导读] 在jquery中实现ajax加载的方法有很多种,不像以前的js的ajax只有那一种,下面我们介绍jquery ajax实现局部加载方法总结,有需要了解的朋友可参考.例 代码如下复制代码 $ ...
- javascript文件加载模式与加载方法
加载方式 形象图像化方法,见 http://www.growingwiththeweb.com/2014/02/async-vs-defer-attributes.html 1. script标签, ...
- js不需要知道图片宽高的懒加载方法(经过实际测试,不加宽高仍然是无法正常加载的,设置height:auto,height:100%,仍然显示高度为0)
js不需要知道图片宽高的懒加载方法 懒加载是如何实现的? - 简书https://www.jianshu.com/p/e86c61468285找到一个不需要知道图片宽高的懒加载方法了(经过实际测试,不 ...
- iOS UI-(多)视图控制器的生命周期、加载方法和模态视图方法以及屌丝方法
#import "ViewController.h" #import "SecondViewController.h" @interface ViewContr ...
- UIImage加载图片的方式以及Images.xcassets对于加载方法的影响
UIImage加载图片的方式以及Images.xcassets对于加载方法的影响 图片缓存 根据是否将创建好的对象缓存入系统内存,有两类创建UIImage对象的方法可选: 缓存:+ imageName ...
- iOS控制器与视图加载方法
转载记录, 请看原文: 1. iOS中的各种加载方法(initWithNibName,loadNibNamed,initWithCoder,awakeFromNib等等)简单使用 http://w ...
- react路由按需加载方法
使用router4之后以前的按需加载方法require.ensure 是不好使了. 所以我们改用react-loadable插件做按需加载. 第一步: yarn add react-loadable ...
随机推荐
- nyist 596 谁是最好的Coder
http://acm.nyist.net/JudgeOnline/problem.php?pid=596 谁是最好的Coder 时间限制:1000 ms | 内存限制:65535 KB 难度:0 ...
- 数组有没有length()这个方法? String有没有length()这个方法?
答:数组和string都没有Length()方法,只有Length属性.
- yii中sphinx索引配置解析
#MySQL数据源配置,详情请查看:http://www.coreseek.cn/products-install/mysql/#请先将var/test/documents.sql导入数据库,并配置好 ...
- mysql设置时区方法
set global time_zone = '+2:00'; ##修改mysql全局时区 set time_zone = '+2:00'; ##修改当前会话时区 flush privileges; ...
- 由linux下的多进程编程引发的关于进程间隔离的思考
源代码放到了三个文件中: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include & ...
- ionic入门之AngularJS扩展基本布局
目录: 标题栏 : ion-header-bar 页脚栏 : ion-footer-bar header/footer : 样式及内容 内容区 : ion-content 滚动框 : ion-scro ...
- yum源的修改
源路径: /etc/yum.repos.d/ 配置文件: 网络搜索 CentOS-Base.repo(默认) 设备搜索 CentOS-Media.repo 将CentOS-Base.repo移除或改名 ...
- Android NDK 开发(二) -- 从Hlello World学起【转】
转载请注明出处:http://blog.csdn.net/allen315410/article/details/41805719 上篇文章讲述了Android NDK开发的一些基本概念,以及NDK ...
- HttpContext.Current.Cache在控制台下不工作
说明: Cache 类不能在 ASP.NET 应用程序外使用.它是为在 ASP.NET 中用于为 Web 应用程序提供缓存而设计和测试的.在其他类型的应用程序(如控制台应用程序或 Windows 窗体 ...
- 将helps.php或者functions.php直接进行了加载
TP3系列中functions.php文件默认其实是空文件,很好找.我们可以直接封装代码. Laravel5系列中的path/vendor/laravel/framework/src/Illumina ...