【笔记】jstree插件的基本使用
json返回参数格式:推荐第二种方式 不需要在重新拼接返回格式
不刷新页面重新初始化 jstree时使用:$.jstree.destroy() 注销已初始化的数据
虚线设置:在 plugins中添加wholerow。如: plugins: ["wholerow","contextmenu"] contextmenu是快捷菜单配置
1、拼接子节点格式
// Expected format of the node (there are no required fields)
{
id : "string" // will be autogenerated if omitted
text : "string" // node text
icon : "string" // string for custom
state : {
opened : boolean // is the node open
disabled : boolean // is the node disabled
selected : boolean // is the node selected
},
children : [] // array of strings or objects
li_attr : {} // attributes for the generated LI node
a_attr : {} // attributes for the generated A node
}
2、根据父节点组装,注:parent是父级节点,初始节点为 " # "
// Alternative format of the node (id & parent are required)
{
id : "string" // required
parent : "string" // required
text : "string" // node text
icon : "string" // string for custom
state : {
opened : boolean // is the node open
disabled : boolean // is the node disabled
selected : boolean // is the node selected
},
li_attr : {} // attributes for the generated LI node
a_attr : {} // attributes for the generated A node
}
html
<div id="treeDiv" > </div>
初始化js
$('#treeDiv').jstree({
'core': {
'data': data//返回的数据
},
});
添加右键点击自定义菜单
$('#treeDiv').jstree({
'core': {
'data': data
},
plugins: ["contextmenu"],
"contextmenu": {
"items": {
"create": null,
"rename": null,
"remove": null,
"ccp": null,
"add": {
"label": "add",
"action": function (obj) {
alert("add operation--clickedNode's id is:" + obj);
}
},
"delete": {
"label": "delete",
"action": function (obj) {
alert("add operation--clickedNode's id is:" + obj);
}
}
}
}
});
虚线设置:在 plugins中添加wholerow。如: plugins: ["wholerow","contextmenu"] contextmenu是快捷菜单配置
拖动效果
$("#treeDiv").jstree({
"core": {
"check_callback": true,
"data":data
},
"plugins": ["dnd"]
});
拖动返回事件
$("#treeDiv").on('move_node.jstree', function (e, data) {
$.post("modulemng/dndmodule", {
id: data.node.id,
parent: data.parent,
position: data.position
}, function (data, status) {
alert("Data: " + data + "\nStatus: " + status);
});
});
初始化完成后展开所有节点
$("#treeDiv").on("ready.jstree", function (e, data) { //树创建完成事件
data.instance.open_all(); //展开所有节点
});
获取当前选择的节点
$("#treeDiv").on('changed.jstree', function (e, data) { //选中节点改变事件
var node = data.instance.get_node(data.selected[0]); //获取选中的节点
});
【笔记】jstree插件的基本使用的更多相关文章
- 利用jstree插件轻松构建树应用
最近完成了项目中的一个树状应用,第一次接触了jstree这个插件,总的来说它的官方文档还是比较详细的,但是在使用过程中还是出现了一些问题,下面我就来谈谈这款插件的使用和心得. 首先项目需要构建一棵树, ...
- 为知笔记markdown插件安装
Wiz.Editor.md 是一个基于 Editor.md 构建的为知笔记 Markdown 插件. 主要特性 多种样式主题 支持实时预览 支持代码高亮 支持搜索替换 支持ToC目录 Tex数学公式 ...
- amazeui学习笔记--js插件(UI增强)--警告框Alert
amazeui学习笔记--js插件(UI增强)--警告框Alert 一.总结 1.警告框基本样式:用am-alert声明div容器, <div class="am-alert" ...
- amazeui学习笔记--js插件(UI增强4)--下拉组件Dropdown
amazeui学习笔记--js插件(UI增强4)--下拉组件Dropdown 一.总结 1.am-dropdown(及其孩子):控制下拉列表的样式 2.data-am-dropdown(及其孩子):控 ...
- amazeui学习笔记--js插件(UI增强3)--折叠面板Collapse
amazeui学习笔记--js插件(UI增强3)--折叠面板Collapse 一.总结 注意点: 1.data-am-collapse:这个东西就是展开折叠事件 2.am-collapse(包括其下属 ...
- amazeui学习笔记--js插件(UI增强2)--按钮交互Button
amazeui学习笔记--js插件(UI增强2)--按钮交互Button 一.总结 1.按钮loading状态: <button type="button" class=&q ...
- jstree 插件的使用笔记(一)
官方:http://www.jstree.com/ 一.节点的描述 官方资料:http://www.jstree.com/docs/json/ 格式一 { id : "string&quo ...
- elasticsearch学习笔记——相关插件和使用场景
logstash-input-jdbc学习 ES(elasticsearch缩写)的一大优点就是开源,插件众多.所以扩展起来非常的方便,这也造成了它的生态系统越来越强大.这种开源分享的思想真是与天朝格 ...
- jsTree插件简介(三)
UI-plugin JSTree的UI插件:用来处理选择.不选和鼠标悬浮树选项的插件. 一.属性包括: 1.select_limit:指定一次可以选中几个节点,默认为-1,表示无限制选中. 2.sel ...
随机推荐
- spring笔记5 spring IOC的基础知识1
1,ioc的概念 Inverse of control ,控制反转,实际的意义是调用类对接口实现类的依赖,反转给第三方的容器管理,从而实现松散耦合: ioc的实现方式有三种,属性注入,构造函数注入,接 ...
- intellij idea 15 修改基础配置加载路径
一.概述 intellij idea 15 默认配置的启动加载路径是"C:\Users\Administrator.IntelliJIdea15",这样会导致占用C盘的空间越来越多 ...
- Java01
1.JAVA历史概述 百度百科:http://baike.baidu.com/view/29.htm 詹姆斯.高斯林 (高司令)----java之父 Sun Micros ...
- ERDAS 2014安装破解及汉化图文教程
关于ERDAS 2014 的安装破解及其汉化过程: 说明:汉化只是之针对英语能力不能正常满足使用软件的朋友们.如果英语过专八,完全没有必要汉化!在此之前查了好多关于ERDAS汉化的文档,可惜只是简单的 ...
- iOS网络3—UIWebView与WKWebView使用详解
一.整体介绍 UIWebView自iOS2就有,WKWebView从iOS8才有,毫无疑问WKWebView将逐步取代笨重的UIWebView.通过简单的测试即可发现UIWebView占用过多内存,且 ...
- swift-运算符
运算符:+ , - , * , / ,%, ++,-- OC和swiftch除了取模运算符,其他用法都一样 可以检测 //var num:UInt8 = 255 + 1 不可以检测 var num1: ...
- Android 开源库和项目 2
1.带尾巴的RecyclerViewPager 特点:1.像viewPager一样滑动一次就滑动一页 2.像画廊gallery一样,滑动一次可以滑动很多页 3.竖向滑动 4.支持点击事件,没有错乱 ...
- (十五)使用Nexus创建Maven私服
通过建立自己的私服,就可以降低中央仓库负荷.节省外网宽带.加速Maven构建.自己部署构件等,从而高效的使用Maven.有三种专门的Maven仓库管理软件可以用来帮助大家建立私服:Apache基金会的 ...
- nginx启动、关闭、重启
1.启动 [root@localhost local]# nginx/sbin/nginx #启动 [root@localhost local]# nginx/sbin/nginx -t #检查配置文 ...
- 个人作业week3——代码复审
1. 软件工程师的成长 感想 看了这么多博客,收获颇丰.一方面是对大牛们的计算机之路有了一定的了解,另一方面还是态度最重要,或者说用不用功最重要.这些博客里好些都是九几年或者零几年就开始学习编 ...