jstree使用【一】初次使用
来源:互联网 发布:网络舆情监测专业 编辑:程序博客网 时间:2024/06/05 11:42
第一步 引入 需要本地引入的可去官方地址下载源码
1.style.min.css
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css" />
2.jquery.min.js
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.1/jquery.min.js"></script>
3.jstree.min.js
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script>
第二步在需要加载jsTree的Html位置处加入
<div id="jstree_vehicle"></div>
第三步写jstree的调用方法
function treeInit(data) { $('#jstree_vehicle').jstree({ 'core': { 'data': { 'url': COMMON.fenbiaoPath + "singleVehicleTrack.queryEntVehicleGroupVehicleTreeInfo.action", 'dataType': "json", 'data': function (node) { return {'vehicleMaster': node.id, 'index': node.type, 'tokenStr': COMMON.token}; } } } }) }
这是一颗异步加载的车辆树,
core.data.url:加载时获取数据的地址
core.data.dataType:获取数据的类型
core.data:异步加载结点数据时,需要向后端接口请求的数据时,所需要传给后端的参数。
jstree支持返回接口数据的格式有两种
第一种:嵌套数据的形式
{ 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}
第二种 指定父id的形式。个人更喜欢使用第二种。值得注意的是第二种形式,必须指定父节点,当第一级为更节点时得指定他的父结点为“#”。
{ 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}
0 0
- jstree使用【一】初次使用
- jstree使用
- jsTree使用
- JSTree使用
- 初次使用gradle(一)
- JQuery的JSTree使用
- jstree 使用API
- playframework中使用JsTree
- jstree 简单使用
- jsTree使用记录
- jstree的使用
- Jstree的使用
- jstree使用心得
- jstree使用教程
- jstree 使用简介
- jsTree 使用笔记
- jstree使用总结
- JsTreeの使用-yellowcong
- HDU 1096
- mysql字段类型选择时float和decimal如何选择
- men
- SAP错误问题汇总
- ExtJS-bootstrap.js的工作方式
- jstree使用【一】初次使用
- 五、数据结构与算法--栈及队列
- Android App罕见错误和优化方案
- Studio android 快捷键文档
- TestNG入门教程
- C# Json转对象 序列化 反序列化
- 最新ueditor(1.4.3.3)版本修改自定义上传路径
- Android中visibility属性VISIBLE、INVISIBLE、GONE的区别
- 【代码笔记】iOS-用户发布后能保存崩溃