Easyui-tree 加载json数据及loadFilter的使用
来源:互联网 发布:少儿编程工具排行榜 编辑:程序博客网 时间:2024/05/07 13:34
一、easyui tree基本使用
首先定义一个<ul>
- <ul id="tt"></ul>
easyui tree 加载json数据:
- $('tt').tree({
- lines:true,//是否显示树线
- url:'tree.json'
- });
json数据要求的格式:下载
- [{
- "id":1,
- "text":"My Documents",
- "children":[{
- "id":11,
- "text":"Photos",
- "state":"closed",
- "children":[{
- "id":111,
- "text":"Friend"
- },{
- "id":112,
- "text":"Wife"
- },{
- "id":113,
- "text":"Company"
- }]
- },{
- "id":12,
- "text":"Program Files",
- "state":"closed",
- "children":[{
- "id":121,
- "text":"Intel"
- },{
- "id":122,
- "text":"Java"
- },{
- "id":123,
- "text":"Microsoft Office"
- },{
- "id":124,
- "text":"Games"
- }]
- },{
- "id":16,
- "text":"Actions",
- "children":[{
- "text":"Add",
- "iconCls":"icon-add"
- },{
- "text":"Remove",
- "iconCls":"icon-remove"
- },{
- "text":"Save",
- "iconCls":"icon-save"
- },{
- "text":"Search",
- "iconCls":"icon-search"
- }]
- },{
- "id":13,
- "text":"index.html"
- },{
- "id":14,
- "text":"about.html"
- },{
- "id":15,
- "text":"welcome.html"
- }]
- }]
其中iconCls表示的图标,这样数据就加载出来了。
二、loadFilter使用
loadFilter可以返回过滤后的数据进行展示
其使用格式:下载
- $('tt').tree({
- url:'tree.json'
- loadFilter:function(data){
- //过滤操作
- return newData;
- }
- });
例:我们从json数据查找text属性值为"Program Files"的树返回展示:下载
- $('tt').tree({
- url:'tree.json'
- loadFilter:function(data){
- for(var i=0; i<data.length; i++){
- if(data[i].text=="Program Files"){
- // 定义一个数组
- var newData = new Array();
- newData.push(data[i]);
- return newData;
- }
- }
- return data;
- }
- });
这里我们可以看到我们使用了数组Array来存放过滤后的数据,这是因为easyui-tree加载json格式的原因,否则加载不出。
0 0
- Easyui-tree 加载json数据及loadFilter的使用
- Easyui-tree 加载json数据及loadFilter的使用
- EasyUI DataGrid的loadFilter属性使用
- 使用EasyUI Tree异步加载JSON数据 生成树
- 使用EasyUI Tree异步加载JSON数据 生成树
- easyui datagrid 的数据加载Json数据
- 生成符合EasyUI-Tree的JSON数据
- easyui 加载json数据
- jquery easyui tree动态加载-服务端struts返回json数据
- easyui的tree加载数据过滤匹配
- easyui tree 模仿ztree 使用扁平化加载json
- EasyUI DataGrid中loadFilter 属性的用法
- EasyUI DataGrid中loadFilter 属性的用法
- EasyUI combobox 加载JSON数据
- Easyui数据表格加载Json的内嵌对象数据
- 使用easyui-combobox的data属性加载定义好在*.js文件中的JSON数据的问题
- easyui-tree中的url属性请求struts2的json数据
- easyui datagrid loadFilter loadData
- spring各jar包的作用
- 智能手机的密码总共有多少种
- msbuild不是内部或外部命令
- Android之Fragment回退栈详解
- centos之lnmp
- Easyui-tree 加载json数据及loadFilter的使用
- 核函数(Kernel Function)整理
- linux下vim对于意外退出的文档的再次开启
- Vim命令合集
- SSL/TLS协议运行机制的概述
- ava.lang.UnsatisfiedLinkError: Couldn't load XXXfrom loader dalvik.system.PathClassLoader[DexPathLis
- 简单的自定义标题栏(不使用Toolbar)
- Vert.x 内核模块 集群管理(十八)
- Cocos2d-x 3.10版本 创建文本