EasyUI为Tree节点增加额外的属性
查看了Tree的节点构造,$.data(_b3[0],"tree-node",{id:_b2.id,text:_b2.text,iconCls:_b2.iconCls,attributes:_b2.attributes});,只有id、text、iconCls和attributes属性,如果要增加⼀些属性,⽐如tag或者userLevel该怎么办呢?
很简单只需要在tree-node的构造⽅法中增加参数:
//在tree-node上增加了tag和mgrlevel属性
$.data(_b3[0],"tree-node",{id:_b2.id,text:_b2.text,iconCls:_b2.iconCls,
tag:_b2.tag,
mgrlevel:_b2.level,
attributes:_b2.attributes});
在后台代码中的json:
Code:
1. HttpRequestRequest=context.Request;
2. HttpResponseResponse=context.Response;
3.
4. SopDataContextdbContext=null;
5. if(context.Application["DBContext"]!=null){
6. dbContext=(SopDataContext)context.Application["DBContext"];
7. }else{
8. dbContext=newSopDataContext();
9. context.Application["DBContext"]=dbContext;
10. }
11.
12. StringBuilderbuilder=newStringBuilder();
easyui插件13. builder.Append("[");
14. List<HRManager>areaManagers=……
15. for(inti=0;i<areaManagers.Count;i++){
16. builder.AppendFormat("{{/"id/":/"{0}/",/"text/":/"{1}/",/"iconCls/":/"icon-
city/",/"state/":/"closed/",/"tag/":/"T{0}/",/"level/":/"
{2}/"}}",areaManagers[i].UserID,areaManagers[i].User.UserName,areaManagers[i].User.MgrLevel);
17. if(i!=areaManagers.Count-1){
18. builder.Append(",");
19. }
20. }
21. builder.Append("]");
22. Response.AddHeader("Content-type","text/json;charset=utf-8");
23. Response.Write(builder.ToString());
24. Response.End();
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论