Chinaunix首页 | 论坛 | 博客
  • 博客访问: 999454
  • 博文数量: 152
  • 博客积分: 4937
  • 博客等级: 上校
  • 技术积分: 1662
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-05 16:55
文章分类

全部博文(152)

文章存档

2013年(12)

2012年(6)

2011年(58)

2010年(43)

2009年(1)

2008年(15)

2007年(17)

我的朋友

分类: Java

2012-12-20 09:20:11

jQuery EasyUI 1.3.1 官方下载地址:
 
 
$(function () {
            $(document).ready(function () {
                $.post("/ORG/ajax/getRoles.aspx", {}, function (json) {
                    $("#tt77").tree({
                        data: json,
                        onClick: function (node) {
                           
                            //----
                            $('#hid').val(node.id);
                            $('#wbs').val(node.attributes);
                            var b = $('#tt77').tree('isLeaf', node.target);
                            if (!b) {
                                return;
                            }
                            //------
                            $.post("/ORG/ajax/getRoles.aspx?id=" + node.id, {
                                "id": node.id
                            }, function (json) {
                                $('#tt77').tree('append', {
                                    parent: node.target,
                                    data: json
                                });
                            }, "json");
 
                        },
                        checkbox: true,cascadeCheck:false
                    });
                }, "json");
            });
        }); 
   
 
内容:
 
     
     
     
    后台代码:
     
    using System.ServiceModel;
    using System.ServiceModel.Web;
    using System.Runtime.Serialization;
    using System.Runtime.Serialization.Json;
     
    protected void Page_Load(object sender, EventArgs e)
            {
                string roleId = Request.QueryString["id"];
                List rolesList = null;
                RendString(Obj2Json(data2Json(rolesList)));
            }
    protected void RendString(string content)
            {
                Response.Clear();
                Response.Write(content);
                Response.End();
            }
    private List data2Json(List list)
            {
                List tnList = new List();
                sys_Roles_bean bean = null;
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
               
                for (int i = 0; i < list.Count; i++)
                {
                    bean = list[i];
                    UTC_IBMP.SYS.TreeNode tn = new UTC_IBMP.SYS.TreeNode(bean.RoleID.ToString(), bean.RoleName, "icon-role");
                    tn.attributes = bean.RoleWBS;
                    tnList.Add(tn);
                }
                return tnList;
            }
            public static string Obj2Json(T data)
            {
                try
                {
                    System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(data.GetType());
                    using (MemoryStream ms = new MemoryStream())
                    {
                        serializer.WriteObject(ms, data);
                        return Encoding.UTF8.GetString(ms.ToArray());
                    }
                }
                catch
                {
                    return null;
                }
            }
     
     
    阅读(6377) | 评论(0) | 转发(0) |
    给主人留下些什么吧!~~