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 ...
随机推荐
- javaapi中的排序
有的时候需要对数组里的element进行排序.当然可以自己编写合适的排序方法,但既然java包里有自带的Arrays.sort排序方法,在 数组元素比较少的时候为何不用? Sorting an Arr ...
- 服务器 CentOS上yum安装Nginx服务
一.更改yum源为网易的源加快速度 vi /etc/yum.repos.d/CentOS-Base.repo 更改内容如下 # CentOS-Base.repo # # This file uses ...
- paper 72 :高动态范围(HDR)图像 HDR (High Dynamic Range)
In standard rendering, the red, green and blue values for a pixel are each represented by a fraction ...
- paper 29 :CV会议+领先研究室+专家+代码网址
做机器视觉和图像处理方面的研究工作,最重要的两个问题:其一是要把握住国际上最前沿的内容:其二是所作工作要具备很高的实用背景.解决第一个问题的办法就是找出这个方向公认最高成就的几个超级专家(看看他们都在 ...
- server端推送消息机制
推送技术相关请参加WIKI: https://zh.wikipedia.org/wiki/%E6%8E%A8%E9%80%81%E6%8A%80%E6%9C%AF 场景: 监控系统:后台硬件温度.电压 ...
- 20道C#练习题(一)1——10题
1.输入三个整数,xyz,最终以从小到大的方式输出.利用if嵌套. Console.Write("请输入x="); double x = double.Parse(Console. ...
- 安装VirtalBox虚拟机的一些问题归纳
1.分别下载VirtalBox软件和镜像,进行安装出现一个问题:换了一个.dll动态库,用管理员权限运行修改BIOS 中Intel Virtual Technology Enabled!2.功能:虚拟 ...
- JS中数组的操作
1.数组的创建 var arrayObj = new Array(); //创建一个数组 var arrayObj = new Array([size]); //创建一个数组并指定长度,注意不是上限, ...
- 如何通过类找到对应的jar包
ctrl+shift+T 然后输入对应类
- 如何在WPF应用程序中使用视频处理控件TVideoGrabber
要在WPF 中使用 TVideoGrabber 组件,需要像下面的方法来使用 VS.NET(DLL) 版本的组件: ——复制TVideoGrabber_x.x.x.x_x86.dll到c:/windo ...