一、前端:

 <div id="tbList" fit="true"></div>

 $(function () {
$("#tbList").treegrid({
url: "/Action/MenuIndex/",
method: 'post',
title: '菜单列表',
idField: 'Id',
treeField: 'Name',
iconCls: 'ext-icon-application_side_tree',
rownumbers: true,
animate: true,
fitColumns: true,
resizable: true,
frozenColumns: [[
{ title: '菜单名称', field: 'Name', width: 200 }
]],
columns: [[
{ title: '排序', field: 'DisOrder', width: 40 },
{ title: '区域名', field: 'AreaName', width: 80},
{ title: '控制器名', field: 'ControllerName', width: 80},
{ title: 'Action方法名', field: 'ActionName', width: 80 },
{
title: 'FormMethod', field: '请求方式', width: 80,
formatter: function (value, row, index) {
return new Object(row["FormMethodDictionary"]).Name;
}
},
{
title: 'OperationType', field: '操作类型', width: 80,
formatter: function (value, row, index) {
return new Object(row["OperationTypeDictionary"]).Name;
}
},
{
field: 'IsShow', title: '显示', width: 25, align: 'center', formatter: function (colData) {
return colData ? "√" : "X";
}
},
{
field: 'IsLink', title: '链接', width: 25, align: 'center', formatter: function (colData) {
return colData ? "√" : "X";
}
},
{ title: '备注', field: 'Remark', width: 150 },
{ title: 'ParentId', field: 'ParentId', hidden: true }
]],
toolbar: [{
text: "添加",
iconCls: 'icon-add',
handler: add
}, '-', {
text: "修改",
iconCls: 'icon-edit',
handler: modify
}, '-', {
text: "删除",
iconCls: 'icon-remove',
handler: remove
}] });
});

二、后端:

 public ActionResult MenuIndex(FormCollection form)
{
//取从数据字典中取中Menu对应的ID号
var dic = _dictionaryService.Single(o => o.Name == "MENU" && o.IsDeleted == false);
var menuId = dic.Id; //查询所有菜单信息
var menus = _actionService.Where(o => o.IsDeleted == false && o.OperationType == menuId && o.IsShow == true, o => o.DisOrder, true, "FormMethodDictionary", "OperationTypeDictionary").ToList(); //构造TreeGrid的数据
RSCC.Model.PageData<ActionViewModel> treegrids = new RSCC.Model.PageData<ActionViewModel>();
treegrids.total = menus.Count();
treegrids.rows = menus.Select(o => o.ToViewModel()).ToList(); //转化为JSON格式
var strJson = operationContext.ToJson(treegrids);
return Content(strJson); }

三、注意事项:

对应的ViewModel中必须有 _parentId 和 state 属性,iconCls 可选。

四、实现效果如下:

  

easyui treegrid的使用示例的更多相关文章

  1. EasyUi TreeGrid封装

    礼物一:树型实体的抽象与封装 所谓树型实体,就是具有树型结构关系的实体,比如省.市.区.对于初学者,可能会创建三张表进行存储,有经验的开发者通过引入ParentId将设计简化为一张表,但是基于Pare ...

  2. 基于EasyUI Treegrid的权限管理资源列表

    1. 前言 最近在开发系统权限管理相关的功能,主要包含用户管理,资源管理,角色管理,组类别管理等小的模块.之前的Web开发中也用过jQueryEasyUI插件,感觉这款插件简单易用,上手很快.以前用到 ...

  3. Jquery easyui treegrid实现树形表格的行拖拽

    前几天修改了系统的一个功能——实现树形列列表的行拖拽,以达到排序的目的.现在基本上功能实现,现做一个简单的总结. 1.拿到这个直接网上搜,有好多,但是看了后都觉得不是太复杂就是些不是特别想看的例子,自 ...

  4. easy-ui treegrid 实现分页 并且添加自定义checkbox

    首先第一点easy-ui  treegrid 对分页没有好的实现, 因为在分页的过程中是按照 根节点来分页的  后台只能先按照 根节点做分页查询  再将子节点关联进去, 这样才能将treegrid 按 ...

  5. easyui treegrid idField 所在属性中值有花括号(如Guid)当有鼠标事件时会报错,行记录一下

    easyui treegrid idField 所在属性中值有花括号(如Guid)当有鼠标事件时会报错,行记录一下

  6. 数据网格和树-EasyUI Datagrid 数据网格、EasyUI Propertygrid 属性网格、EasyUI Tree 树、EasyUI Treegrid 树形网格

    EasyUI Datagrid 数据网格 扩展自 $.fn.panel.defaults.通过 $.fn.datagrid.defaults 重写默认的 defaults. 数据网格(datagrid ...

  7. EasyUI treegrid 加载checked

    EasyUI treegrid  加载checked $(function () { $('#tbDictContTree').treegrid({ title: '数据字典目录管理', iconCl ...

  8. Easyui treegrid 无法显示树形结构解决办法

    easyui treegrid 中检查了数据结构没有问题的,但就是不展示树形结构, 检查发现原来是 var columnsAll = [ { title: '任务ID', field: 'TaskID ...

  9. 适用于zTree 、EasyUI tree、EasyUI treegrid

    #region          System.Text.StringBuilder b_appline = new System.Text.StringBuilder();        Syste ...

随机推荐

  1. Oracle实现行转列+Mybatis

    1.需求 报表需要动态展示某几个公司分别在几个月内销售额情况(前端表头月份是动态的,月时间段是前端参数来选择的,最大为12个月), 页面展示如下 Oracle数据库中数据如下: 可以看到一个公司的月份 ...

  2. CF 398 E(动态规划)

    传送门: http://codeforces.com/problemset/problem/398/E 题解: 首先答案不超过2. 最长环=1时,ans=0 最长环=2时,ans=1 否则,ans=2 ...

  3. checkbox与文字对齐

    checkbox和后面的文字如果不加样式,会导致checkbox和文字对齐,解决办法是对checkbox和文字同时添加如下样式: vertical-align:middle;

  4. NX二次开发-将工程图上的每个视图导出PNG图片

    大概思路是将每个视图导出PDF,在调另一个项目的EXE(PDF转PNG) //ExportDrawViewPng // Mandatory UF Includes #include <uf.h& ...

  5. CodeForces1249B1/B2-Books Exchange-dfs-一般搜索+记忆化搜索

    一般搜索 注意:一般定义成void Books Exchange (easy version)  CodeForces - 1249B2 The only difference between eas ...

  6. 深入理解 js为什么没有函数重载,如何实现函数重载?

    我的新博客 http://www.suanliutudousi.com/2017/08/24/%E6%B7%B1%E5%85%A5%E7%90%86%E8%A7%A3-js%E4%B8%BA%E4%B ...

  7. python 15 文件操作(一)

    转自 http://www.cnblogs.com/BeginMan/p/3166644.html 一.文件对象 我理解的文件对象就是一个接口,通过这个接口对文件进行相关操作. <Python ...

  8. 在Logstash的配置文件中对日志事件进行区分

    1.多个日志文件作为输入源 input { # 通过给日志事件定义类型来区分 file { path => ["/var/log/nginx/access.log"] typ ...

  9. linux下使用自带mail发送邮件

    linux下使用自带mail发送邮件 mailx工具说明: linux可以通过安装mailx工具,mailx是一个小型的邮件发送程序,一般可以通过该程序在linux系统上,进行监控linux系统状态并 ...

  10. Oracle SQL外连接

    SQL提供了多种类型的连接方式,它们之间的区别在于:从相互交叠的不同数据集合中选择用于连接的行时所采用的方法不同.连接类型        定义内连接           只连接匹配的行左外连接     ...