.net mvc mssql easyui treegrid
效果图

数据图 可以看到 这里是根据 MenuNo 来 分级别的,支持 无限极,第一级是 01 ,第二级就是 01XX ,第三级 就是 01XXOO。类似 id、pid ,Ztree 里面 也是这样的。

@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml"; //模板 里面 有 easyui 需要的 js 、css
}
<table id="ttt" title="测试二" class="easyui-treegrid" style="width: 700px; height: 250px"
data-options="
rownumbers: true,@*显示行号*@
idField: 'id',
treeField: 'name' ,
">
<thead>
<tr>
<th data-options="field:'name'" width="">name</th>
<th data-options="field:'name2'" width="" align="right">name2</th>
</tr>
</thead>
</table>
<table id="tttt" title="测试三" class="easyui-treegrid" style="width: 700px; height: 850px"
data-options="
rownumbers: true,
idField: 'Id',
treeField: 'MenuName' ,
">
<thead>
<tr>
<th data-options="field:'MenuName'" width="">MenuName</th>
<th data-options="field:'Url'" width="" align="left">Url</th>
</tr>
</thead>
</table>
<script>
$(document).ready(function () {
// 测试 本地 加载
var jsonstr = {
"total": , "rows": [
{ "id": , "name": "所有部门", name2: "", "_parentId": },
{ "id": , "name": "广东省", name2: "", "_parentId": },
{ "id": , "name": "广州市", name2: "", "_parentId": },
{ "id": , "name": "深圳", name2: "", "_parentId": },
{ "id": , "name": "白云区", name2: "", "_parentId": },
{ "id": , "name": "天河区", name2: "", "_parentId": }
]
};
$("#ttt").treegrid("loadData", jsonstr);
//ajax 加载
$.ajax({
type: 'POST', url: '@Url.Action("IndexTestData")', dataType: 'JSON', async: false, success: function (data) {
$("#ttt").treegrid("loadData", data);
}
});
$.ajax({
type: 'POST', url: '@Url.Action("Index")', dataType: 'JSON', async: false, success: function (data) {
$("#tttt").treegrid("loadData", data);
}
});
});
</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using KT_Product_Show_Market.Areas.Account.Models;
using Newtonsoft.Json; namespace KT_Product_Show_Market.Areas.Account.Controllers
{
public class TestController : Controller
{
KT_Product_MarketEntities db = new KT_Product_MarketEntities();
protected override void Dispose(bool disposing)
{
db.Dispose();
base.Dispose(disposing);
} public ActionResult Index()
{
return View();
} public class depts
{
public int id, _parentId; public string name, name2;
} [HttpPost]
[ActionName("IndexTestData")]
public string IndexSrarchTest()
{
List<depts> arr = new List<depts>() {
new depts() { id = , name = "所有部门", name2="", _parentId = },
new depts() { id = , name = "广东省", name2="", _parentId = },
new depts() { id = , name = "广州市", name2="", _parentId = },
new depts() { id = , name = "深圳", name2="", _parentId = },
new depts() { id = , name = "白云区", name2="", _parentId = },
new depts() { id = , name = "天河区", name2="", _parentId = },
};
var obj = new KT_Product_Show_Market.Models.DataGridJson(); //创建EasyUI DataGrid 所需格式对象
var All = arr;
obj.total = All.Count(); //总行数
obj.rows = All.ToList(); //获当前页数据集
return JsonConvert.SerializeObject(obj, Formatting.Indented, new JsonSerializerSettings() { DateFormatHandling = });
} [HttpPost]
[ActionName("Index")]
public string IndexSrarch()
{
var obj = new KT_Product_Show_Market.Models.DataGridJson(); //创建EasyUI DataGrid 所需格式对象
var All = db.Database.SqlQuery<Sys_Menu_tree>("select MenuNo as 'Id',substring(MenuNo,1,len(MenuNo)-2) as '_parentId',MenuName,Url from Sys_Menu ");
obj.total = All.Count(); //总行数
obj.rows = All.ToList(); //获当前页数据集
return JsonConvert.SerializeObject(obj, Formatting.Indented, new JsonSerializerSettings() { DateFormatHandling = });
}
public class Sys_Menu_tree
{
public string Id { get; set; }
public string _parentId { get; set; }
public string MenuName { get; set; }
public string Url { get; set; }
}
}
}
public class DataGridJson
{
public int total { get; set; } //记录的总条数
public object rows { get; set; } //具体内容
}
其实 easyui 没什么难度,因为官方的文档资料很全面。下载easyui 文档之后,比如说要看treegrid 支持的 json格式 可以找到:

虽然 例子 都是 php 的。但是 原理 都差不多。
.net mvc mssql easyui treegrid的更多相关文章
- .net mvc mssql easyui treegrid 及时 编辑 ,支持拖拽
这里提到了,1个问题,怎么扩展 Easyui 参见: http://blog.csdn.net/chenkai6529/article/details/17528833 @{ ViewBag.Titl ...
- EasyUi TreeGrid封装
礼物一:树型实体的抽象与封装 所谓树型实体,就是具有树型结构关系的实体,比如省.市.区.对于初学者,可能会创建三张表进行存储,有经验的开发者通过引入ParentId将设计简化为一张表,但是基于Pare ...
- 基于EasyUI Treegrid的权限管理资源列表
1. 前言 最近在开发系统权限管理相关的功能,主要包含用户管理,资源管理,角色管理,组类别管理等小的模块.之前的Web开发中也用过jQueryEasyUI插件,感觉这款插件简单易用,上手很快.以前用到 ...
- [转]Spring3 MVC + jQuery easyUI 做的ajax版本用户管理
原文地址:http://www.iteye.com/topic/1081739 上周写了篇基于spring3.0.5 mvc 简单用户管理实例 ( http://www.iteye.com/topic ...
- Jquery easyui treegrid实现树形表格的行拖拽
前几天修改了系统的一个功能——实现树形列列表的行拖拽,以达到排序的目的.现在基本上功能实现,现做一个简单的总结. 1.拿到这个直接网上搜,有好多,但是看了后都觉得不是太复杂就是些不是特别想看的例子,自 ...
- 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(7)-MVC与EasyUI DataGrid
原文:构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(7)-MVC与EasyUI DataGrid 没有源码的同学跳到第六讲下载源码再来. 我们需要漂亮的UI, ...
- mvc+ef5+easyui实例(1)
mvc+ef5+easyui 组织机构和员工管理实例 环境:vs2010+sql2008 框架搭建 1,新建mvc4 web应用 2. 3. 系统自动生成的的controllers,和views文件中 ...
- MVC与EasyUI结合增删改查
构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(9)-MVC与EasyUI结合增删改查 在第八讲中,我们已经做到了怎么样分页.这一讲主要讲增删改查.第六讲的 ...
- easy-ui treegrid 实现分页 并且添加自定义checkbox
首先第一点easy-ui treegrid 对分页没有好的实现, 因为在分页的过程中是按照 根节点来分页的 后台只能先按照 根节点做分页查询 再将子节点关联进去, 这样才能将treegrid 按 ...
随机推荐
- 如何从Terminal Command Line编译并运行Scope
Ubuntu SDK我们大部分的开发者是非常有效的.它甚至可以帮助我们进行在线调试.在这篇文章中,我们介绍了如何使用command line编译和执行我们scope. 1)创建一个主Scope 我们能 ...
- 电脑知识--Windows一片
.com档 Dos可执行命令文件,一般小于64kb, .com文件包括程序的一个绝对映像.就是说,为了执行程序准确的处理器指令和内存中的数据.Ms-Dos通过直接把该映像从文件复制到内存. 而 载入. ...
- HDU 5012 Dice (BFS)
事实上是非常水的一道bfs,用字符串表示每一个状态,map判重就ok了. 题目链接:http://acm.hdu.edu.cn/showproblem.php? pid=5012 #include&l ...
- HDU - 5186 - zhx's submissions (精密塔尔苏斯)
zhx's submissions Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- Chapter 3 Protecting the Data(3):创建和使用数据库角色
原版的:http://blog.csdn.net/dba_huangzj/article/details/39639365.专题文件夹:http://blog.csdn.net/dba_huangzj ...
- iOS coreData
static int row=0; static const NSString *kStoryboardName = @"LRCoreDataViewController"; st ...
- AndroidManifest:VersionCode和VersionName
Google为APK定义了两个关于版本号属性:VersionCode和VersionName,他们有不同的用途. VersionCode:对消费者不可见.仅用于应用市场.程序内部识别版本号,推断新旧等 ...
- Bye,IE!服务互联网20年IE终于要退役了
美国当地时间16日中午,Microsoft Edge官微发表了祝词:Internet Explorer 20岁生日快乐!你在过去做出了巨大贡献,今后由我继续发扬光大.服务互联网20年之后,IE终于要退 ...
- NSIS:静默释放文件并运行 制作绿色单文件软件
原文 NSIS:静默释放文件并运行 制作绿色单文件软件 现在所谓的绿色单文件软件,大多与以下代码原理相似:把软件运行需要的文件封装为一个EXE文件,双击时释放到某个目录(大多是TEMP)并运行主程序文 ...
- emacs quick open and jump file (or buffer) which name is current word
Sometime, we need to open a file or buffer which name begin with current word in emacs. Here I give ...