Exemple #1
0
        public static HtmlGenericControl CreateUl(TreeViewSettings settings)
        {
            HtmlGenericControl ul = new HtmlGenericControl("ul");

            if (!string.IsNullOrEmpty(settings.Id))
            {
                ul.Attributes.Add("id", String.Format("{0}_rootUl", settings.Id));
            }
            ul.Attributes.Add("class", String.Format("{0} {1}", "rootUl", settings.Header.Expanded || !settings.Header.Visible ? string.Empty : "hiddenUl").TrimEnd());

            return(ul);
        }
Exemple #2
0
        public static HtmlGenericControl CreateTreeHeaderContainer(TreeViewSettings settings, string id, string containerCssClass, string contentCssClass)
        {
            HtmlGenericControl container = new HtmlGenericControl("div");

            if (!string.IsNullOrEmpty(containerCssClass))
            {
                container.Attributes.Add("class", containerCssClass);
            }

            if (!string.IsNullOrEmpty(id))
            {
                container.Attributes.Add("id", String.Format("{0}_header", settings.Id));
            }

            if (settings.Header.Visible)
            {
                HtmlGenericControl expand  = new HtmlGenericControl("a");
                HtmlGenericControl content = new HtmlGenericControl("span");

                if (!string.IsNullOrEmpty(id))
                {
                    expand.Attributes.Add("id", string.Format("Expander_{0}", id));
                    content.Attributes.Add("id", string.Format("Content_{0}", id));
                }

                if (!string.IsNullOrEmpty(settings.Header.Text))
                {
                    content.InnerText = settings.Header.Text;
                }

                if (settings.Header.Expanded)
                {
                    expand.Attributes.Add("class", "collapse");
                }
                else
                {
                    expand.Attributes.Add("class", "expand");
                }

                if (!string.IsNullOrEmpty(contentCssClass))
                {
                    content.Attributes.Add("class", contentCssClass);
                }

                container.Controls.AddAt(0, expand);
                container.Controls.AddAt(1, content);
            }
            return(container);
        }
Exemple #3
0
        public static HtmlGenericControl CreateDataContainer(TreeViewSettings settings, HtmlGenericControl content, List <Node> data)
        {
            HtmlGenericControl divData = new HtmlGenericControl("div");

            divData.Attributes.Add("id", String.Format("{0}_JsonData", settings.Id));
            divData.Attributes.Add("style", "display:none;");

            JavaScriptSerializer jSer = new JavaScriptSerializer();

            jSer.MaxJsonLength = int.MaxValue;

            divData.InnerText = jSer.Serialize(data);

            return(divData);
        }
Exemple #4
0
        public static HtmlGenericControl CreateScripts(TreeViewSettings settings)
        {
            HtmlGenericControl script = new HtmlGenericControl("script");

            script.Attributes.Add("type", "text/javascript");

            StringBuilder html = new StringBuilder();

            html.AppendLine(@"$(document).ready(function () {");
            html.AppendLine(String.Format(@"$('#{0}').SharkDevTreeView({{", settings.Id));
            html.AppendLine(String.Format(@"'AutoCompleteHandler': '{0}',", settings.AutoCompleteHandler));
            html.AppendLine(String.Format(@"'AfterSelectHandler': {0},", settings.ClientHandlers.ContentSelect));
            html.AppendLine(String.Format(@"'DataOnClient': {0}", settings.DataOnClient.ToString().ToLower()));
            html.AppendLine("});");
            html.AppendLine("});");

            script.InnerHtml = html.ToString();
            return(script);
        }
Exemple #5
0
        public static HtmlGenericControl CreateTree(TreeViewSettings settings, HtmlGenericControl container, List <Node> data)
        {
            HtmlGenericControl tree = new HtmlGenericControl("div");

            if (settings.Width > 0)
            {
                tree.Attributes.Add("style", String.Format("width:{0}px;", settings.Width));
            }

            tree.Attributes.Add("id", settings.Id);
            tree.Attributes.Add("class", "sharkTreeView");
            tree.Controls.AddAt(0, TreeStructureCreator.CreateScripts(settings));
            tree.Controls.AddAt(1, TreeStructureCreator.CreateAutocompleteContainer("search", "search", String.Format("{0}_autoCompleteInput", settings.Id), "autoCompleteInput", "progressParent", "progress"));
            tree.Controls.AddAt(2, TreeStructureCreator.CreateTreeHeaderContainer(settings, 0.ToString(), "header", "headerspan"));
            tree.Controls.AddAt(3, TreeStructureCreator.CreateTreeContainer(container, settings, "tree"));

            if (settings.DataOnClient)
            {
                tree.Controls.AddAt(4, TreeStructureCreator.CreateDataContainer(settings, container, data));
            }

            return(tree);
        }
Exemple #6
0
 public TreeView(TreeViewSettings settings)
 {
     _treeViewSettings = settings;
 }
Exemple #7
0
        public static HtmlGenericControl CreateTreeContainer(HtmlGenericControl content, TreeViewSettings settings, string cssClass)
        {
            HtmlGenericControl mainDiv = new HtmlGenericControl("div");

            mainDiv.Controls.AddAt(0, content);
            mainDiv.Attributes.Add("class", cssClass);
            mainDiv.Attributes.Add("id", String.Format("{0}_tree", settings.Id));
            if (settings.Height > 0)
            {
                mainDiv.Attributes.Add("style", String.Format("height:{0}px;", settings.Height));
            }

            return(mainDiv);
        }