Beispiel #1
0
    /// <summary>
    /// Creates tree content.
    /// </summary>
    public void FillTree()
    {
        treeElem.Nodes.Clear();

        if (string.IsNullOrEmpty(ValidationHelper.GetString(TreePath, string.Empty)) && (Level == 0))
        {
            return;
        }
        // Create tree with Level0 to LevelN
        else if (string.IsNullOrEmpty(TreePath))
        {
            CreateLevelTree();
        }

        // Split leafs in tree path
        string[] levels = TreePath.Split('/');

        if (levels.Length > 0)
        {
            string rootName = GetString("InheritLevels.RootName");

            // Own user ID
            if (levels.Length > 1)
            {
                // Begin from index 1, first item is empty string
                if (!string.IsNullOrEmpty(levels[1]))
                {
                    rootName = levels[1];
                }
            }

            TreeNode root = new TreeNode("<span onclick=\"return false;\" class=\"ContentTreeItem\"><span class=\"Name\"><strong>" + HTMLHelper.HTMLEncode(rootName) + "</strong></span></span>", "0");
            root.ToolTip      = rootName;
            root.ImageToolTip = string.Empty;
            TreeNode LastNode = root;

            // Insert other nodes
            for (int i = 2; i < levels.Length; i++)
            {
                string currentLevel = levels[i];
                if (ValidationHelper.GetString(currentLevel, "") != "")
                {
                    TreeNode currentNode = new TreeNode("<span onclick=\"return false;\" class=\"ContentTreeItem\"><span class=\"Name\">" + HTMLHelper.HTMLEncode(currentLevel) + "</span></span>", (i - 1).ToString());
                    currentNode.ToolTip      = currentLevel;
                    currentNode.ImageToolTip = "";
                    LastNode.ChildNodes.Add(currentNode);
                    LastNode = currentNode;
                }
            }

            treeElem.Nodes.Add(root);
            treeElem.ExpandAll();
        }
    }