EasyUI生成treegrid的json格式

时间:13-03-25 栏目:EasyUI, Net 作者:zongyan86 评论:0 点击: 12,285 次

 

List<DepartmentEntity> listDept = new List<DepartmentEntity>{
new DepartmentEntity(){DepId=1,DepName="1部门",ParentId=0,Description="超级管理员",ShowOrder=1,IsShow=0},
new DepartmentEntity(){DepId=2,DepName="2部门",ParentId=0,Description="管理员",ShowOrder=2,IsShow=0},
new DepartmentEntity(){DepId=3,DepName="jjj",ParentId=0,Description="jjj",ShowOrder=3,IsShow=0},
new DepartmentEntity(){DepId=4,DepName="jiui",ParentId=1,Description="jjjjyyuuu",ShowOrder=4,IsShow=0},
new DepartmentEntity(){DepId=5,DepName="dd",ParentId=4,Description="jjj",ShowOrder=3,IsShow=0},
new DepartmentEntity(){DepId=6,DepName="fff",ParentId=5,Description="jjjjyyuuu",ShowOrder=4,IsShow=0}
};

var listDeptByID = listDept.Where(q => q.ParentId == id).Select(s =>
new
{
DepId = s.DepId
,
DepName = s.DepName
,
_parentId = s.ParentId
,
state = listDept.Any(y => y.ParentId == s.DepId) ? "closed" : null
,
ShowOrder = s.ShowOrder
,
Description = s.Description

}
).OrderBy(o => o.DepId);

var vResult = new { rows = listDeptByID };
var vReturn = JsonConverter.Parse(vResult);
context.Response.Write(vReturn);

 

public class DepartmentEntity
{

//public DepartmentEntity()
//{
//    this.children = new List<DepartmentEntity>();
//}
public int DepId { get; set; }
public string DepName { get; set; }
public int ParentId { get; set; }
public int ShowOrder { get; set; }
public int IsShow { get; set; }
public string Description { get; set; }
//public string iconCls { get; set; }
//public IList<DepartmentEntity> children { get; set; }
}

 



声明: 本文由( zongyan86 )原创编译,转载请保留链接: EasyUI生成treegrid的json格式

EasyUI生成treegrid的json格式:等您坐沙发呢!

发表评论



热搜关键词: easyui   开发   web开发
广告虚位以待

读者排行

关注我们