OptGroupListBox - Additional functionality suggestion

Jul 17, 2008 at 7:15 PM
Edited Jul 18, 2008 at 2:33 PM
Hello,

First and foremost, thanks for creating this AWESOME control.

The application I am building is using a 3-tier cascading OptGroupListbox type of set up to select data sources for building Cross-Tabulations on some data we have. Each piece of data is it's own list item. SOME of the data can stand-alone by itself (it shows up as just a <option> with no parent <optgroup> tag. Some of the data is not stand-alone though and should be encapsulated in an option grouping.

The option for the listboxes come from a data-table that is built from a DB. I iterate through the data-table and if a column in the DT is "single" it just does obj.AddItem(). Once the loop encounters a qType of "matrix" it executes AddGroup().

Essentially my problem is that when you add an OptGroup, the control assumes that all AddItems() belong to the last open optgroup. There is no way to tell the control that it needs to close the last opened optgroup tag. I think there should be a function added to OptGroup's for handling these types of things.

Also if yo know a way i can get around this that would be awesome!

Here is the code I'm using so ya can get a better idea of what I'm trying to do

            string CurrentOptGroupQ;
                      CurrentOptGroupQ = "";
            bool HasOpenOptGroup;
                    HasOpenOptGroup = false;            
            string RemovalChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
           
            foreach (DataRow dr in QAreasDT.Rows)
            {
                if (dr["qtype"].ToString().ToLower() == "matrix")
                {
                    X_QAREA.AddGroup(dr["qText"].ToString(),null);
                    CurrentOptGroupQ = dr["questionNumber"].ToString();
                    HasOpenOptGroup = true;
                }
                if (dr["qtype"].ToString().ToLower() == "single")
                {
                    if (dr["questionNumber"].ToString().TrimEnd(RemovalChars.ToCharArray()) == CurrentOptGroupQ)
                    {
                        X_QAREA.AddItem(dr["qText"].ToString(), dr["questionNumber"].ToString());
                    }
                    else
                    {
                        CurrentOptGroupQ = "";
                        if (HasOpenOptGroup)
                        {
                            HasOpenOptGroup = false;
                           
                            // This is where I want to forcably close the optgroup

                            X_QAREA.AddItem(dr["qText"].ToString(), dr["questionNumber"].ToString()); // next question

                        }
                        else
                        {
                            X_QAREA.AddItem(dr["qText"].ToString(), dr["questionNumber"].ToString());
                        }
                       
                    }
                }
Coordinator
Jul 17, 2008 at 7:57 PM
Hello, MonkeeOfEvil and thanks for your feedback.

We are planning a new release of the project shortly, in which the OptGroupDropDownList is redesigned, for ease of use and more flexibility.
In the future release, your problem is solved.

You'll be able to control the opening and closing of the optgroup tags using a property called GroupingType, which can be: None, Inherit or New.
So, in your case, if you don't want items inside a group, you just set the item's GroupingType to none and that's it.

Thanks again for your feedback,
Raul