easyui tree 编辑后保留原先状态

 

 

    

    $(function () {
        var selected = $('#depttree').tree('getSelected');
        $('#depttree').tree({
            checkbox: false,
            animate: true,
            url: '/Provider/HandlerCommon.ashx?method=getdepttree&parentid=<%=deptid%>',
            onClick: function (node) {
                //  $(this).tree('toggle', node.target);
                // $("#url3").attr("src", "PersonMain.aspx?deptid="+node.id)
                //    $('#treeuserinf').datagrid({ url: '/Provider/HandlerPerson.ashx', queryParams: { 'deptid': node.id} });
                //  var selected = $('#Admin_List').datagrid('getSelected');
                $('#Admin_List').datagrid({ url: '/Provider/HandlerPersonList.ashx?method=list', queryParams: { 'deptid': node.id} });
                // alert(node.id);


            }, onSelect: function (node) {
                deptid = node.id;
            },
            onExpand: function (node) {
                expandid = node.id;
            },
            onLoadSuccess: function (row, data) {
                var roots = $('#depttree').tree('getRoots');
                var childs = $('#depttree').tree('getChildren', roots[0].target); //alert(childs.length);

                for (j = 0; j < childs.length; j++) {

                    $('#depttree').tree('collapse', childs[j].target);

                }
                if (deptid == roots[0].id) {
                    $('#depttree').tree('select', roots[0].target);
                    $('#depttree').tree('expand', roots[0].target);
                }

                for (j = 0; j < childs.length; j++) {
                    if (deptid == childs[j].id) {
                        $('#depttree').tree('select', childs[j].target);
                     
                    }
                    if (expandid == childs[j].id) { 
                         $('#depttree').tree('expand', childs[j].target);
                    }
                }



            }
        });
    });

  

posted on 2013-08-19 22:57  gwazy  阅读(1904)  评论(0编辑  收藏  举报

导航