jsTree checkbox plugin使用笔记
2024-08-31 01:58:53
引入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
});
}
});
};
最新文章
- Serializable接口和transient关键字
- 他答对一半(打一字)asp.net开源简答题项目
- redis 可视化工具
- vue学习笔记之属性和方法
- Easy Problem-map和vector的使用
- Linux命令行修改IP、网关、DNS的方法
- thinkphp 前后版本ajaxReturn方法的分别
- 图文教程:手把手教你用U盘安装Ubuntu
- [ZZ] matlab中小波变换函数dwt2和wavedec2 系数提取函数appcoef2和detcoef2
- VB6 二维数组去重实现
- windows10的环境变量path如何列表显示
- oracle instantclient_11_2 配置文件tnsnames.ora
- topcoder srm 460 div1
- 解决spring-boot启动异常Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean
- poj3468 A Simple Problem with Integers(线段树/树状数组)
- JavaScript绝句的小研究
- iOS实现基于VLC播放器的封装效果
- .net MVC 单页面 多个(行)数据修改
- 如何查看DNS?
- Oracle 补丁体系 及 opatch 工具 介绍
热门文章
- [Bzoj4196] [NOI2015] 软件包管理器 [树链剖分,线段树]
- Debug : array type has incomplete element type
- nyoj_114_某种序列_201403161700
- natural join 以及 v$statname , v$sessstat
- A*(也叫A star, A星)寻路算法Java版
- xpath元素查找提示is not clickable
- MapReduce:具体解释Shuffle过程
- COCOS学习笔记--Button类及其相关控件属性
- SpringMVC + MyBatis 配置文件
- vmware上安装ubuntu和vmwaretools