项目说明,要一个有权限并且按需加载的树形列表.

jeasyui网址

CSS

<!--添加树状控件-->
<link rel="stylesheet" type="text/css" href="../js/GridTree/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../js/GridTree/themes/default/serviceTesting1.css">

HTML

<div id="tableMain">
<table class="easyui-treegrid" id="funTreeList" style="width: 100% !important;"></table>
</div>

JS

<!--treeGrid树状插件-->
<script type="text/javascript" src="../js/GridTree/jquery.easyui.min.js"></script> //找到自己的文件目录 <script>
  
function GetModuleTree(){
$.ajax({
type: "get",
url: durl+"ServicePrice/GetSystemModulePriceTree",
data: {},
cache: false,
success: function (d) {
var data = d.data;
$('#funTreeList').treegrid({
fit: true,
toolbar: '#toolbar',
striped: true,
rownumbers: false, //设置为true,则显示带有行号的列
lines:true, //是否出现线条
fitColumns:true, //设置为true,则会自动扩大或缩小列的尺寸以适应网格的宽度并且防止水平滚动。
data: data, //加载的数据 (此数据为父级和子集的全部数据)
idField:'ModuleID', //指示那个字段是标识字段
treeField:'ModuleName', //定义树节点的字段
loadFilter: myLoadFilter, //最主要的方法 过滤数据
onLoadSuccess: function (row) {
          $('#funTreeList').treegrid('collapseAll')
obj.q(); //权限
closeload();
},
columns:[[
{field:'ModuleName',title:'功能名称',width:200},
{field:'ModuleSort',title:'功能序号',width:40},
{field:'ModuleID',title:'功能ID',width:40},
{field:'ModuleIndustry',title:'适用行业',width:60},
{field:'ModuleRemark',title:'功能简介',width:100,formatter:ModuleRemark},
{field:'IsMenu',title:'首页菜单',align:'center', width:40,formatter:IsMenu},
{field:'priceType',title:'定价点',align:'center', width:150,formatter:priceType},
{field:'btns',title:'操作',align:'center',width:270,formatter:formatOper}
]]
   });
},
error: function (a, b, c) {
closeload();
alert("请求服务器出现错误");
}
});
}
//按需加载子节点
function myLoadFilter(data,parentId){
function setData(data){//重新整理数据的children属性
var todo = [];
for(var i=0; i<data.length; i++){
todo.push(data[i]);//数组末端添加 将源数据添加到数组中便于后续利用
} while(todo.length){
var node = todo.shift();//方法用于把数组的第一个元素从其中删除,并返回第一个元素的值。
if (node.children){//如果有子节点
node.state = 'closed';
node.children1 = node.children;
node.children = undefined;
todo = todo.concat(node.children1);//数组联结
       }
}
}
setData(data);
var tg = $(this);//当前页面
var opts = tg.treegrid('options');//获取属性表格的属性对象
//节点展开前执行的方法 row是行数据
  opts.onBeforeExpand = function(row){
if (row.children1){
tg.treegrid('append',{
parent: row[opts.idField],//父节点id
data: row.children1//节点数据
});
row.children1 = undefined;
}
obj.q(); //权限
return row.children1 == undefined;
};
return data;
}
</script>

Jquery EasyUI Treegrid按需加载子集的更多相关文章

  1. jquery easyui easyui-treegrid 使用异步加载数据

    jquery easyui easyui-treegrid 使用异步加载数据 jquery easyui easyui-treegrid 异步请求 >>>>>>&g ...

  2. easyui combogrid 按需加载,点击下拉加载

    功能优点:减少不必要的http请求,减少服务器查询压力,降低额外的浏览器渲染,提高呈现速度开发分享: combogrid 点击才请求的功能实现简要:我分析了费用系统,和现在全网的写法.并不满意.都是要 ...

  3. jQuery easyui datagrid 的数据加载

        其实easyuidatagrid加载数据只有两种方式:一种是ajax加载目标url返回的json数据:另一种是加载js对象,也就是使用loadDate方法,这种方法用于加载本地js数据(非ur ...

  4. Jquery EasyUI tree 的异步加载(遍历指定文件夹,根据文件夹内的文件生成tree)

    private void SMT(HttpContext context) { string SqlConnection82 = System.Configuration.ConfigurationM ...

  5. jquery easyui:tab自动加载第一个tab内容

    $('#resourceTabs').tabs('unselect', 0);$('#resourceTabs').tabs('select', 0);

  6. jqGrid -treeGrid 按需加载

    Load Rows On Demand (AJAX) 参考:http://www.guriddo.net/demo/treegridjs/

  7. [转载]再次谈谈easyui datagrid 的数据加载

    这篇文章只谈jQuery easyui datagrid 的数据加载,因为这也是大家谈论最多的内容.其实easyui datagrid加载数据只有两种方式:一种是ajax加载目标url返回的json数 ...

  8. 谈谈easyui datagrid 的数据加载(转)

    这篇文章只谈jQuery easyui datagrid 的数据加载,因为这也是大家谈论最多的内容.其实easyui datagrid加载数据只有两种方式:一种是ajax加载目标url返回的json数 ...

  9. 再次谈谈easyui datagrid 的数据加载

    from:http://www.easyui.info/archives/204.html 这篇文章只谈jQuery easyui datagrid 的数据加载,因为这也是大家谈论最多的内容.其实ea ...

随机推荐

  1. (转)jQuery基础之选择器

    原文地址: http://www.cnblogs.com/webmoon/p/3169360.html 选择器是jQuery的根基,在jQuery中,对事件处理.遍历DOM和Ajax操作都依赖于选择器 ...

  2. Mathematical optimization数学上的最优化

    https://en.wikipedia.org/wiki/Mathematical_optimization In mathematics, computer science and operati ...

  3. memcpy用法

    函数原型 void *memcpy(void*dest, const void *src, size_t n); 功能 由src指向地址为起始地址的连续n个字节的数据复制到以destin指向地址为起始 ...

  4. Js杂谈-单体模式

    单体模式的思想:保证一个特定类仅有一个实例,意味着第二次使用同一个类创建新对象的时候,应该得到与第一次所创建对象完全相同的对象. 下面举几个实现的例子 1.new操作符 这种思想在于当使用同一个构造函 ...

  5. windows phone开发必备工具翔

    1.图标设计 http://www.flaticon.com/ http://www.iconfont.cn/ 2.界面设计: 2.1.behance.com    2.2.dribbble.com  ...

  6. 检查Windows上安装的.net版本

    cmd reg query "HKLM\Software\Microsoft\NET Framework Setup\NDP" /s /v version | findstr /i ...

  7. Socket网络通讯

    网络编程 使用C#进行网络编程时,通常都需要用到System.Net命名空间.System.Net.Sockets命名空间和System.Net.Mail命名空间: 1. System.Net命名空间 ...

  8. 《C#多线程编程实战》1.10 lock关键字

    lock关键字是锁定资源用的. 书上的代码解释很好. /// <summary> /// 抽象类 加减法 /// </summary> abstract class Count ...

  9. kafka启动报错Cannot allocate memory;There is insufficient memory for the Java Runtime Environment to continue.

    kafka启动过程报错,配置没有问题,这就懵了!! Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000 ...

  10. Weekly Contest 117

    965. Univalued Binary Tree A binary tree is univalued if every node in the tree has the same value. ...