引入css文件
<link rel="stylesheet" type="text/css" href="js/assets/global/plugins/jstree/dist/themes/default/style.min.css" />
引入js文件
<script type="text/javascript" src="js/assets/global/plugins/jstree/dist/jstree.min.js"></script> 前端放一个div用来做为tree的容器
<div style="overflow-y: auto; overflow-x: auto; width: 100%; height: 534px;" id="jstree_bsbm_div"></div> //构造树型结构
var handleTree = function() { getTreeData();
$("#jstree_bsbm_div").on('select_node.jstree', function(node,selected,event) {
//绑定选中事件处理函数
id = selected.node.id;
parent = selected.node.parent;
jc = selected.node.original.jc;
// jcMax = selected.node.original.jcMax;
// gz = selected.node.original.gz;
freshtable();
}).on('refresh.jstree', function(node,selected,event) {
//刷新事件处理函数
getTreeData();
});
}; //获取树形数据
var getTreeData = function(){
var aData = {
type: "2",
roledm: roledm,
}
$.ajax({
type : "POST",
url : "basic/getQxTree",
dataType : "json",
contentType : 'application/json', //定义格式
data : JSON.stringify(aData), //把json转为String传递给后台
success : function(data) {
// var data = [
// { "id" : "ajson1", "parent" : "#", "text" : "Simple root node" ,'state' : {'selected' : true}},
// { "id" : "ajson2", "parent" : "#", "text" : "Root node 2" ,'state' : {'selected' : true}},
// { "id" : "ajson3", "parent" : "ajson2", "text" : "Child 1" ,'state' : {'selected' : false}},
// { "id" : "ajson4", "parent" : "ajson2", "text" : "Child 2" ,'state' : {'selected' : true}},
// ]; $('#jstree_bsbm_div').data('jstree', false).empty();
$("#jstree_bsbm_div").jstree({
'core': {
'data': data,
},
plugins: [ "wholerow", "checkbox","types","themes"],
"checkbox": {
"keep_selected_style": false,//是否默认选中
},
}) // 获取树
var menuTrees = $('#jstree_bsbm_div').jstree(true);
// 清空级联关系
var oldCascade = menuTrees.settings.checkbox.cascade;
menuTrees.settings.checkbox.cascade = '';
// 重置级联关系
setTimeout(function () {
menuTrees.settings.checkbox.cascade = oldCascade;
}, 500); },
error : function(e) {
Metronic.alert({
type: 'danger',
icon: 'warning',
message: '树形数据获取失败!',
place: 'prepend',
closeInSeconds:5,
container:'#profileAlertsMsg',
focus:true
});
}
});
};

最新文章

  1. Serializable接口和transient关键字
  2. 他答对一半(打一字)asp.net开源简答题项目
  3. redis 可视化工具
  4. vue学习笔记之属性和方法
  5. Easy Problem-map和vector的使用
  6. Linux命令行修改IP、网关、DNS的方法
  7. thinkphp 前后版本ajaxReturn方法的分别
  8. 图文教程:手把手教你用U盘安装Ubuntu
  9. [ZZ] matlab中小波变换函数dwt2和wavedec2 系数提取函数appcoef2和detcoef2
  10. VB6 二维数组去重实现
  11. windows10的环境变量path如何列表显示
  12. oracle instantclient_11_2 配置文件tnsnames.ora
  13. topcoder srm 460 div1
  14. 解决spring-boot启动异常Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean
  15. poj3468 A Simple Problem with Integers(线段树/树状数组)
  16. JavaScript绝句的小研究
  17. iOS实现基于VLC播放器的封装效果
  18. .net MVC 单页面 多个(行)数据修改
  19. 如何查看DNS?
  20. Oracle 补丁体系 及 opatch 工具 介绍

热门文章

  1. [Bzoj4196] [NOI2015] 软件包管理器 [树链剖分,线段树]
  2. Debug : array type has incomplete element type
  3. nyoj_114_某种序列_201403161700
  4. natural join 以及 v$statname , v$sessstat
  5. A*(也叫A star, A星)寻路算法Java版
  6. xpath元素查找提示is not clickable
  7. MapReduce:具体解释Shuffle过程
  8. COCOS学习笔记--Button类及其相关控件属性
  9. SpringMVC + MyBatis 配置文件
  10. vmware上安装ubuntu和vmwaretools