.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 按 ...
随机推荐
- 文件搜索神器everything 你不知道的技巧总结
everything这个软件用了很久,总结了一些大家可能没注意到的技巧,分享给大家 1.指定文件目录搜索示例: TDDOWNLOAD\ abc 在所有TDDOWNLOAD文件夹下搜索包含 ...
- asp.net弹出层实例
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.c ...
- POJ 3009-Curling 2.0(DFS)
Curling 2.0 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12158 Accepted: 5125 Desc ...
- ExtJs--02--MessageBox相关弹出窗口alert,prompt,confirm采用
/* Ext.onReady(function(){ Ext.MessageBox.alert("jack","tom"); Ext.MessageBox.al ...
- 使用shell/python获取hostname/fqdn释疑(转)
一直以来被Linux的hostname和fqdn(Fully Qualified Domain Name)困惑了好久,今天专门抽时间把它们的使用细节弄清了. 一.设置hostname/fqdn 在Li ...
- NOI第一天感想&小结
嘛...中午总算是到了深圳了--在虹桥机场和飞机上和市队大神们一起讨论各种各样奇(sang)葩(bing)的算(ren)法(lei)还是非常开心的,在此再各种膜拜一下尽管没来比赛的FFT大神@陈中瑞 ...
- 谈论高并发(十二)分析java.util.concurrent.atomic.AtomicStampedReference看看如何解决源代码CAS的ABA问题
于谈论高并发(十一)几个自旋锁的实现(五岁以下儿童)中使用了java.util.concurrent.atomic.AtomicStampedReference原子变量指向工作队列的队尾,为何使用At ...
- C++实现链表
最后几天留在Intel,没什么事情,都是开开会.趁着闲功夫,把数据结构复习一下,写了一个list.时间仓促,有些地方考虑的可能没那么到位,望高手们指点. #include <iostream&g ...
- .NET单元测试艺术(3) - 使用桩对象接触依赖
List 3.1 抽取一个设计文件系统的类,并调用它 [Test] public bool IsValidLogFileName(string fileName) { FileExtensionMan ...
- Oracle数据表被drop后的恢复
对于被drop的表和索引,都会存放在回收站中(所以对于生产的数据库必须设置好回收站功能) 由于本次生成环境在drop掉已有的表后,又一次创建了很多的表,全部直接还原的话会提示原有对象存在,表名反复.当 ...