1
Vote

ExtendedListBox OptGroup ID

description

I have a requirement that has a need for an ID in the OptGroup, which is currently not being generated.
Here's a fix for the ExtendedListbox.cs for the WriteOptionsGroup method:
 
/// <summary>
    /// Writes the option group.
    /// </summary>
    /// <param name="item">The item.</param>
    /// <param name="writer">The writer.</param>
    private void WriteOptionGroup(ExtendedListItem item, HtmlTextWriter writer)
    {
        if (_optGroupStarted)
            writer.WriteEndTag("optgroup");
 
        writer.WriteBeginTag("optgroup");
        writer.WriteAttribute("label", item.GroupingText);
        writer.WriteAttribute("id", String.Format("{0}{1}", this.ClientID, item.GroupingText));  // new id attribute
        if (!item.Enabled)
            writer.WriteAttribute("disabled", "disabled");
        if (!string.IsNullOrEmpty(item.GroupCssClass))
            writer.WriteAttribute("class", item.GroupCssClass);
        writer.Write('>');
        // writer.WriteLine();
        _optGroupStarted = true;
    }

comments

ra00l wrote Dec 23, 2008 at 8:32 PM

Thanks for your suggestion, I will add an option to also render an ID for the control.
However, I will change a bit the code, to clean spaces and other special characters.

Thanks for your interest!
Raul

CitizenBane wrote Dec 28, 2008 at 4:09 AM

Thanks Raul. I'll be around!

ra00l wrote Jan 15, 2009 at 9:24 AM

It's added, for now in the Source code, but it will be in the next release.

Have a look at the AutoGroupID and GroupID properties.

Thanks,
Raul

wrote Feb 14, 2013 at 2:12 AM