JSON

EasyUI生成treegrid的json格式

字号+ 作者:H5之家 来源:H5之家 2015-11-02 16:04 我要评论( )

ListDepartmentEntity listDept = new ListDepartmentEntity{new DepartmentEntity(){DepId=1,DepName=

 

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格式

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • 生成JSON元数据对象的典型技巧

    生成JSON元数据对象的典型技巧

    2016-01-24 16:00

  • 从XML生成可和Ajax共同使用的JSON.doc

    从XML生成可和Ajax共同使用的JSON.doc

    2016-01-15 18:21

  • 生成JSON格式的重写toString方法

    生成JSON格式的重写toString方法

    2016-01-15 18:22

  • php自学系列(1)PHP生成json数据

    php自学系列(1)PHP生成json数据

    2015-11-24 16:19

网友点评