Creating drop down dynamically using TemplateItemList

Last post 03-24-2008, 12:08 PM by sfcalvert. 2 replies.
Sort Posts: Previous Next
  •  03-20-2008, 6:09 PM 38215

    Creating drop down dynamically using TemplateItemList

    I need to create the toolbar dynamically from a comma separated list stored in a database. Additionally, I would like those items to be created in groups, like how they are when defined in the XML file (g_start, g_end). Adding g_start and g_end to the comma separated list doesn't work. How do I group items this way?
     
    Additionally, I need to create a custom drop down list for syntax highlighting. How would I do this using the TemplateItemList method of toolbar loading? Is this possible? Would it be better to write an HttpHandler that writes the XML file dynamically?
     
    Please provide code examples with your answer. Thanks.

  •  03-24-2008, 10:59 AM 38295 in reply to 38215

    Re: Creating drop down dynamically using TemplateItemList

  •  03-24-2008, 12:08 PM 38298 in reply to 38295

    Re: Creating drop down dynamically using TemplateItemList

    OK, great. That works for creating groups and line breaks. How do I now go about adding a custom drop down list using the TemplateItemsList property?
     
    Currently if I add an item to the TemplateItemsList property string, such as [SyntaxHighlighting], I of course just get a placeholder. I'm adding the control like so:
     

        private void AddCustomDropDown()
        {
            ToolControl control = this.uxEditor.ToolControls["SyntaxHighlighting"];
            if (control != null)
            {
                RichDropDownList syntaxHighlighter = new RichDropDownList(this.uxEditor);
                syntaxHighlighter.Width = Unit.Pixel(100);
                syntaxHighlighter.Attributes.Add("onchange", "$EX.highlightSyntax(this);");
                string[] languages = "cpp,c#,css,delphi,pascal,java,javascript,php,python,ruby,sql,vb,xml,html,xhtml,xslt".Split(',');

                syntaxHighlighter.Items.Add(new RichListItem("Highlight Syntax"));

                foreach (string language in languages)
                {
                    syntaxHighlighter.Items.Add(new RichListItem(language));
                }

                control.Control.Controls.Add(syntaxHighlighter);
            }
        }
     
    This adds my item, but you will notice the default item had to be added using syntaxHighlighter.Items.Add(new RichListItem("Highlight Syntax")); I would rather not do it this way, as the item now appears in my drop down list, unlike adding it the other way (XML method using a config file). Is there any way to get around this? Also, it doesn't display correctly in Firefox. As you can see from the image below, the drop down now appears to overlap the Size drop down.
     


    Any solution to this?
View as RSS news feed in XML