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 = 1 , name = " 所有部门 " , name2= " 3 " , _parentId = 0 },
new depts() { id = 2 , name = " 广东省 " , name2= " 3 " , _parentId = 1 },
new depts() { id = 3 , name = " 广州市 " , name2= " 3 " , _parentId = 1 },
new depts() { id = 4 , name = " 深圳 " , name2= " 3 " , _parentId = 1 },
new depts() { id = 5 , name = " 白云区 " , name2= " 3 " , _parentId = 2 },
new depts() { id = 6 , name = " 天河区 " , name2= " 3 " , _parentId = 2 },
};
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 = 0 });
}
[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 = 0 });
}
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的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did119046