一、前端:

 <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 可选。

四、实现效果如下:

  

最新文章

  1. Ruby中字符串与正则表达式的问题
  2. Hadoop 数据库 - HBase
  3. Lua windows环境搭建
  4. How to check “hasRole” in Java Code with Spring Security?
  5. UIDynamic仿物理引擎-浮动碰撞效果-b
  6. JAVA_SE复习(basic)
  7. CC EAL认证
  8. LAMP第三部分php,mysql配置
  9. Linux 监测命令
  10. Mongodb中 Documents文档说明
  11. SQL Server 常用函数使用方法
  12. liunx命令简介
  13. JDK线程池的拒绝策略
  14. new和malloc的用法和区别
  15. LoadRunner改脚本
  16. 【Git】从服务器搭建到提交分支使用——初学者轻松上手篇
  17. 分享一个Panda C-60 维修心得
  18. 20145222何志威《网络对抗》- Web安全基础实践
  19. Crystal Report Error: Either the Crystal Reports registy key permission are insufficient or the Crystal Reports runtime is not installed correctly
  20. java代码将e.printStackTrace()写入log4j文件异常信息

热门文章

  1. jQuery 遍历 - eq() 方法
  2. bzoj1001题解
  3. 1 visual studio code 配置C++开发环境 (windows 开发环境)
  4. 随意从Android端抓取一些数据包看到的协议
  5. Linux下rsync的安装及简单使用
  6. pathlib生成文件的软链接
  7. Python匹马行天下之_循环
  8. codis 使用
  9. ES6 学习 -- let const
  10. mysql 04_章基本查询