<%@ Control Language="C#" AutoEventWireup="true" Inherits="Usercontrols_classTree" Codebehind="classTree.ascx.cs" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<script type="text/javascript">
    var __tablename = '<%=ClassTableName%>';
    var __isfirstload= true;
    var setting = {
        async: {
            enable: true,
            url: 'GetClassNode.aspx?classtablename='+__tablename+'&cid=',
            autoParam: ["id", "name=n", "level=lv"],
            otherParam: { "otherParam": "zTreeAsync" },
            dataFilter: filter
        },
        callback: {
            onClick: onClick,
            onAsyncSuccess: function(treeobj, treeid) {
                if (__isfirstload) {
                    var zTree = $.fn.zTree.getZTreeObj("treeDemo");
                    var node = zTree.getNodeByParam("id", "000");
                    if(node!=null)
                    {
                        zTree.expandNode(node, true, null, null, false);
                    }
                    __isfirstload=false;
                }
            }
        }
    };
    function onClick(event, treeId, treeNode, clickFlag) {
        _currrentselectnodeid = treeNode.id;
        document.getElementById("FrameClassEdit").src = "ClassTreeEdit.aspx?classtablename=" + __tablename + "&cid=" + treeNode.id + "&timespan=" + new Date().getTime();
       }
       function filter(treeId, parentNode, childNodes) {
           if (!childNodes) return null;
           for (var i = 0, l = childNodes.length; i < l; i++) {
               childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
           }
           return childNodes;
       }

       function RefreshNode(v_nodeId) {
           if (v_nodeId=="") {
               this.location.href = this.location.href;
               return;
           }
           var zTree = $.fn.zTree.getZTreeObj("treeDemo");
           var node = zTree.getNodeByParam("id", v_nodeId);
           if (node != null) {
               if (node.isParent) {
                   zTree.reAsyncChildNodes(node, "refresh", false);
               }
               else {
                   if (v_nodeId.length > 3) {
                       RefreshNode(v_nodeId.substring(0, v_nodeId.length - 3));
                   }
                   else {
                       RefreshNode("000");
                   }
               }
           }
       }

       $(document).ready(function() {
           $.fn.zTree.init($("#treeDemo"), setting);
       });
	</script>
  <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td align="center" style="width:200px;height:600px;border:1px solid gray;font-size:14px;" valign="top">
            <ul id="treeDemo" class="ztree"></ul>
    </td>
      <td align="center" valign="top" style="height:600px;border:1px solid gray">
           <iframe src="ClassTreeEdit.aspx?classtablename=<%=ClassTableName%>" id="FrameClassEdit" frameborder="0" width="100%" height="600" scrolling="yes"></iframe>
    </td>
    </tr>
    </table>
    

    