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