This is a migrated thread and some comments may be shown as answers.

Empty Item Feature Request

7 Answers 59 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 21 Jul 2011, 02:44 PM
Checking in on this request....is it in Q2 by any chance?

Property of something like "InsertEmptyItemOnDataBind"...so I wouldn't have to keep handling OnDataBound to add a empty\null item to the top of the list in every combobox?

7 Answers, 1 is accepted

Sort by
0
Thad
Top achievements
Rank 2
answered on 21 Jul 2011, 03:51 PM
Hi Steve,

I'm pretty sure this is not in the Q2 release, but this is how I have gotten around this problem.  Like you, I don't like having to hard code a default item into the markup each time I put a RadComboBox on a page.

namespace SampleApp.ServerControls
{
 
    /// <summary>
    /// Normal RadComboBox with support for a default item to be added when databound
    /// </summary>
    public sealed class RadComboBoxWithDefault : RadComboBox
    {
        public string DefaultItemText { get; set; }
        public string DefaultItemValue { get; set; }
 
        /// <summary>
        /// Insert a default item when data bound
        /// </summary>
        /// <param name="e"></param>
        protected override void OnDataBound(EventArgs e)
        {
            base.OnDataBound(e);
            var defaultText = String.IsNullOrEmpty(DefaultItemText) ? "Select..." : DefaultItemText;
            var defaultValue = String.IsNullOrEmpty(DefaultItemValue) ? "-1" : DefaultItemValue;
            Items.Insert(0, new RadComboBoxItem(defaultText, defaultValue));
        }
    }
}

Then I just add this control to the page instead and voila!!

<uc:RadComboBoxWithDefault id="rcbSample" runat="server" DefaultItemText="Select a country..." DefaultItemValue="-1">

Hope that helps you or someone else.
-Thad
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 21 Jul 2011, 06:57 PM
Hey Thad,
  Yeah that's a good workaround at the moment :)  ...I'll probably impliment this today instead of the multiple DataBound events....Did not occur to me to just do a simple usercontrol wrapper.

it's a pretty important (basic) feature would you not agree?....I guess it gets more complicated with webservice binding...but an empty item I use 85% of the time when using RadCombo.

Now @Telerik...please still impliment this as a feature please :)  Just becasue we have a functional workaround doesn't mean it's not a feature people would want...and perhaps I would argue that since people ARE making wrappers\workarounds that should raise some sort of flag?

Steve
0
Thad
Top achievements
Rank 2
answered on 21 Jul 2011, 08:30 PM
Hi Steve,

We use the server control approach for several different scenarios where we want different common implementations of the RadComboBox.  It is very useful.

I'm hard pressed to say that this should be cooked into the base control.  It would definitely be handy to have, but I have to say I'd probably still wrap the base RadComboBox in a server control because we utilize this method to enforce site standards like MaxHeight and EmptyMessage, remove animation because it slows down the users' experience, and provide standard binding, validation, and inspection methods.

I'd rather that Telerik work on features that we have no work around for, like further enhancing the CheckBoxes property support so that the Text propery isn't read-only, or expanding on the clientside API of the RadListView so that we can have an API like the RadGrid where we can easily iterate the items and find controls without writing tons of jQuery.  Better yet, separating out the RadComboBox into two controls -- one with CheckBoxes and one without would make me happy because then each control could be as lean as possible while still sharing a common base class.  But that's just me.  :-)

I think I saw someone else suggest this same feature over in PITS, so hopefully this will get implemented for you!

Regards,
Thad
0
Simon
Telerik team
answered on 27 Jul 2011, 02:49 PM
Hi guys,

@Steve We have this feature logged in our PITS and we will implement it in the near future. I hope this is good news for you.

@Thad Thank you for the feedback. Could you please elaborate more on the Text issue when CheckBoxes are enabled? How will you use this custom text?

Regards,
Simon
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Thad
Top achievements
Rank 2
answered on 27 Jul 2011, 03:06 PM
Hi Simon,

Thanks for the response.  Here is a forum post that explains what I need to be able to accomplish:
http://www.telerik.com/community/forums/aspnet-ajax/combobox/setting-text-via-javascript-when-checkboxes-true.aspx

And good news for you, Steve!!

Thad
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 27 Jul 2011, 03:07 PM
It is indeed!...I have a party scheduled for friday :D
0
Simon
Telerik team
answered on 28 Jul 2011, 05:58 PM
Hello again guys,

@Steve Awesome. Have a great time :)

@Thad Thank you for the reference. I see what you are having difficulties with and since Kalina already has responded to your questions I do not have anything to add.

Regards,
Simon
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
ComboBox
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
Thad
Top achievements
Rank 2
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Simon
Telerik team
Share this question
or