html部分

<div class="widget-main padding-8" style="height:400px;overflow-y: scroll;"><!-- overflow-y: scroll css样式,切割显示 -->
  <ul id="res_tree"></ul>
</div>

《jqgrid》部分

var allResTree;//所有菜单tree
$.ajax("${ctx!}/sys/role/getAllResTree", {
  dataType: "json"
}).done(function(data) {
  if(SQ.isFAIL(data)){
    allResTree = null;
  }else{
    allResTree = data;
    $("#role_auth #res_tree").ace_tree({
      multiSelect: true,
      cacheItems: true,
      'open-icon' : 'ace-icon tree-minus',
      'close-icon' : 'ace-icon tree-plus',
      'itemSelect' : true,
      'folderSelect': false,
      'selected-icon' : 'ace-icon fa fa-check',
      'unselected-icon' : 'ace-icon fa fa-times',
      loadingHTML : '<div class="tree-loading"><i class="ace-icon fa fa-refresh fa-spin blue"></i></div>',
      dataSource: function(options, callback){
      var $data = null;
      if(!("text" in options) && !("type" in options)){
        $data = allResTree;//the root tree
        callback({ data: $data });
        return;
      }
else if("type" in options && options.type == "folder") {
if("children" in options)
$data = options.children || {};
else $data = {}//no data
}
if($data != null)//this setTimeout is only for mimicking some random delay
setTimeout(function(){callback({ data: $data });} ,0);
}
});
$("#role_auth #res_tree").tree('discloseAll');

}
});

$("#role_auth").on("show.bs.modal", function() {
$('#role_auth #res_tree').tree('deselectAll');
});
$("#role_auth").on("hidden.bs.modal", function() {
//$(this).removeData("bs.modal");
});

var authId;
function authRole(id){
if(!allResTree){
bootbox.alert("数据获取失败,请刷新页面或联系管理员!");
return;
}
$.ajax("${ctx!}/sys/role/getResListByRole/" + id, {
dataType: "json"
}).done(function(data) {
if(SQ.isFAIL(data)){
bootbox.alert(SQ.getMessage(data));
}else{
$("#role_auth").modal({
backdrop :'static'
});
authId = id;
//$('#role_auth #res_tree').tree('discloseAll');
$("#role_auth #res_tree").tree('selectAll', data);
//$("#role_auth #role_auth_title").html();
}
});
}

$("#role_auth #btn_save").on('click', function(){
var ids = $('#role_auth #res_tree').tree('selectedIds');
if(SQ.isNullOrEmpty(ids)){
bootbox.alert("请至少给他一个权限!");
return;
}
$("#role_auth #btn_save").prop("disabled", true);//按钮失效
$.ajax("${ctx!}/sys/role/updateRoleRes", {
async: false,type: "POST",
data: {roleId: authId, resIds: ids.toString()},
dataType: "json"
}).done(function(data) {
if(SQ.isFAIL(data)){
bootbox.alert("保存失败:"+SQ.getMessage(data), function(){
$("#role_auth #btn_save").prop("disabled", false);
});
}else{
bootbox.alert("保存成功:"+SQ.getMessage(data), function(){
$("#role_auth #btn_close").click();
$("#role_auth #btn_save").prop("disabled", false);
//$("#role_grid").jqGrid().trigger("reloadGrid");//重新载入数据
});
}
});
});

//全选
$("#role_auth #btn_all").on('click',function(){
$("#role_auth #btn_all").prop("disabled", true);//按钮失效
$.ajax("${ctx!}/sys/role/getResAll", {
dataType: "json"
}).done(function(data) {
if(SQ.isFAIL(data)){
bootbox.alert(SQ.getMessage(data));
}else{
$("#role_auth #res_tree").tree('selectAll', data);//根据ID将对应的选项填充选中
$("#role_auth #btn_all").prop("disabled", false);//按钮有效
}
});
});

后台代码

//所有可授权菜单
public void getAllResTree(){
  List<MainRes> list = MainRes.dao.queryAllCommonRes();
  renderJson(StringUtil.getTreeJson(list, MainRes.Id, MainRes.Name, MainRes.Pid));
}

数据库

public List<MainRes> queryAllCommonRes(){
  String sql = "select id,ifnull(pid,0) as pid,name from main_res where is_delete = 0 and ifnull(permission,0) = 0 ";
  return dao.find(sql);
}

bootstrap ace treeview树表的更多相关文章

  1. hangfire+bootstrap ace 模板实现后台任务管理平台

    前言 前端时间刚开始接触Hangfire就翻译了一篇官方的教程[翻译+山寨]Hangfire Highlighter Tutorial,后来在工作中需要实现一个异步和定时执行的任务管理平台,就结合bo ...

  2. 在bootstrap ace样式框架上修改的后台管理型模板(Tab页后台管理模板)

    后台管理模板开始用frameset布局,但是有时候会遮挡比如上面导航或者左边导航的二级三级弹出菜单,因为宽度被限制了,所以有时候就用easyui或者ext的,但是样式不好看,然后看到了bootstra ...

  3. 基于Bootstrap Ace模板+bootstrap.addtabs.js的菜单

    这几天研究了基于bootstrap Ace模板+bootstra.addtabs.js实现菜单的效果 参考了这个人的博客 https://www.cnblogs.com/landeanfen/p/76 ...

  4. MVC遇上bootstrap后的ajax表单模型验证

    MVC遇上bootstrap后的ajax表单验证 使用bootstrap后他由他自带的样式has-error,想要使用它就会比较麻烦,往常使用jqueyr.validate的话只有使用他自己的样式了, ...

  5. JS组件系列——基于Bootstrap Ace模板的菜单和Tab页效果分享(你值得拥有)

    前言:最近园子里多了许多谈语言.谈环境.谈逼格(格局)的文章,看看笑笑过后,殊不知其实都是然并卵.提升自己的技术才是王道.之前博主分享过多篇bootstrap组件的文章,引起了很多园友的关注和支持,看 ...

  6. winform中生成TreeView树

    无论是webform还是winform,TreeView都是常用功能.使用递归方法很方便. 下面分享一个小实例. 数据库中3个字段,分别是:ID,itemType_name,itemType_PID ...

  7. Bootstrap系列 -- 12. 水平表单

    Bootstrap框架默认的表单是垂直显示风格,但很多时候我们需要的水平表单风格(标签居左,表单控件居右) 在Bootstrap框架中要实现水平表单效果,必须满足以下两个条件: 1.在<form ...

  8. ext树表

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAA2UAAAHwCAIAAACpIFDdAAAgAElEQVR4nOy9f5Qb5ZnvWWQZlnO5Oc ...

  9. Asp.net MVC4 Knockoutjs BootStrap Ace NinJect Jqgrid sqlserver2008

    Asp.net MVC4 Knockoutjs  BootStrap Ace NinJect  Jqgrid sqlserver2008

随机推荐

  1. 奥迪--Q3

    -型号:Q3 -价格:23-35W -动力:1.4T/2.0T -变速箱:6挡双离合/7挡双离合 -长宽高:4.40,1.84,1.59 -油箱:64L -发动机:EA888 -大灯:氙气(选装LED ...

  2. 固定某一元素在某一位置 jquery

    方法: $(window).scroll(function (){}) 属性: 滚动变化值 $(window).scrollTop();$(window).scrollLeft(); 需要结合的样式: ...

  3. oracle 多表查询

    1.注意点 在查询过程中,不确定数据库表中的数据量,先查询数据量,数据量较大,则不能直接查询(select * from emp),如果数据量较大,直接查询容易造成死机或者数据读取较慢,如果较小可以查 ...

  4. centos 6.X 安装scrapy-原创

    特别注意[坑]: python版本一定大于 2.7.5,scrapy python 必须2.7以上centos 6.X系列 系统默认安装的python是2.6.6 ,本人折腾了很久2.7.3 在这里升 ...

  5. PHP MongoDB 扩展安装配置

    近日对MongoDB比较感兴趣,在linux下部署了一套LAMP,想把MongoDB加进来,下面进入正题: 1.确保安装好LAMP环境,假设php安装目录:/usr/local/php5 2.下载ht ...

  6. Allowed memory size Out of memory ini_set('memory_limit', '-1');

    Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 51 bytes) ini_set(' ...

  7. [转]百度MP3音乐API接口及应用

    当你在百度去搜索一首歌时,你会发现有种更简单的方法,嘿嘿,告诉你个秘密,百度有个不公开的API http://box.zhangmen.baidu.com/x?op=12&count=1&am ...

  8. struts1 plugin

    struts plugin 在struts.xml中注册之后,在系统启动之后调用 init 方法,通常在init方法中进行转化器的注册,在destory中移除转化器 1. struts文件 <p ...

  9. (转) java 简单工厂模式(实现一个计算器)

    package com.simpleFactory; /** * 运算类 * @author Administrator * */ public class Operation { private d ...

  10. RelativeLayout不能调用measure去直接测量子元素

    RelativeLayout在实现onMeasure方法时并没有像LinearLayout一样去重写如下代码: @Override protected void onMeasure(int width ...