Need a Feature

6 posts, 0 answers
  1. Steve
    Steve avatar
    1888 posts
    Member since:
    Dec 2008

    Posted 04 May 2011 Link to this post

    Can you decorate the first and last items in the combobox with rcbFirst\rcbLast or something like that...or make that decoration toggleable with a property?

    (does this exist?)

    My designer gave me a complex style to implement, and I need those to style the item reliably cross-browser (still IE6 *eugh*)

    This is a common site-wide skin in which we can't use templates everywhere to get around it, I need it to be on the root object itself so the skin can define it.

    Can you guys add that in pretty please? :)
  2. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 09 May 2011 Link to this post

    Hi Steve,

    I am afraid that implementing different styles for the first and for the last RadComboBox item is not officially supported.
    However there is one approach that you can try.
    You can handle the OnClientDropDownOpening event and add specific styling to the first and to the last RadComboBox items in this way:
    <style type="text/css">
        .first
        {
            background-color: Blue;
        }
        .last
        {
            background-color: Red;
        }
    </style>
     
    <script type="text/javascript">
     
        function OnClientDropDownOpening(sender, eventArgs) {
            // find the first element
            var first = sender.get_items().getItem(0);
            if (first != null) {
                var firstLI = first.get_element();
                firstLI.className += " first";
            }
     
     
            var itemsCount = sender.get_items().get_count();
            // find the last element
            var last = sender.get_items().getItem(itemsCount - 1);
            if (last != null) {
                var lastLI = last.get_element();
                lastLI.className += " last";
            }
     
     
        }
    </script>
     
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server" />
            <telerik:RadComboBox ID="RadComboBox1" runat="server"
                EnableEmbeddedSkins="false"
                OnClientDropDownOpening="OnClientDropDownOpening">
                <Items>
                    <telerik:RadComboBoxItem Text="item 1" Value="1" />
                    <telerik:RadComboBoxItem Text="item 2" Value="2" />
                    <telerik:RadComboBoxItem Text="item 3" Value="3" />
                </Items>
            </telerik:RadComboBox>
        </div>
        </form>
    </body>

    Please note that in such scenario most probably you will have to implement a custom skin.

    Kind regards,
    Kalina
    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.

  3. Steve
    Steve avatar
    1888 posts
    Member since:
    Dec 2008

    Posted 09 May 2011 Link to this post

    Yeah I realize it's not officially supported :)

    But can you please add it to PITS as a feature request?

    I can't implement it as a coded solution (client or server) because it needs to be a CSS thing so the other developers can just drop a combo onto their pages and the .Skin file will handle the rest.
  4. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 12 May 2011 Link to this post

    Hello Steve,

    Since the item styling that you describe can be easily achieved, I am afraid that we cannot consider it as a feature.
    I can suggest you one more very simple approach how to style the first and last RadComboBox items.
    You can handle the OnDataBound event and set the CssClass property of the first and last item in this way:

    <head runat="server">
        <title></title>
        <style type="text/css">
        .first
        {
            background-color: Blue;
        }
        .last
        {
            background-color: Red;
        }
    </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <telerik:RadComboBox ID="RadComboBox1" 
            runat="server"
            OnDataBound="OnDataBound" >
        </telerik:RadComboBox>
        </div>
        </form>
    </body>

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.RadComboBox1.DataSource = CreateDataSource();
            this.RadComboBox1.DataTextField = "Name";
            this.RadComboBox1.DataValueField = "ID";
            this.RadComboBox1.DataBind();
        }
        
    }
     
    protected void OnDataBound(object sender, EventArgs e)
    {
        RadComboBox combo = (RadComboBox)sender;
        RadComboBoxItem firstItem = combo.Items[0];
        firstItem.CssClass = "first";
     
        RadComboBoxItem lastItem = combo.Items[combo.Items.Count - 1];
        lastItem.CssClass = "last";
    }


    Regards,
    Kalina
    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.

  5. Steve
    Steve avatar
    1888 posts
    Member since:
    Dec 2008

    Posted 12 May 2011 Link to this post

    Since the item styling that you describe can be easily achieved, I am afraid that we cannot consider it as a feature.

    Are you perhaps not understanding my use-case for this?...I can't implement ask developers to put this code in EVERY page EVERY time.  Some of them are already having a hard time with basic stuff like setting DropDownWidths consistantly.

    Let me give you an example:
    http://demos.telerik.com/aspnet-ajax/panelbar/examples/functionality/simple/defaultcs.aspx

    RadPanelBar...

    Has .rpFirst and .rpLast appended to the first and last items...I'm sure it was easy to implement there in a databound event as well, however they were nice enough to implement it for us as it probably solved some styling issues on their end as well.

    The reason we use these controls is to help improve development time.  I fail to see why this is a bad idea, like it couldn't be plugged in over someones lunch hour.  Like your code shows, it's not that hard to do.

    All I ask is you put it inside of PITS so we can decide if it's a feature that people like to see...
  6. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 13 May 2011 Link to this post

    Hello Steve,

    I understand your frustration.

    Still this is a rather minor feature, which will only increase the rendered output of RadComboBox (it is already too heavy).

    We added a PITS item and in the meanwhile I suggest you create a custom type, inheriting from RadComboBox, which encapsulates the code given to you by Kalina and reuse it in your project instead of RadComboBox. In this way, you will achieve the desired result without many hurdles.

    I hope this is acceptable for you.

    Greetings,
    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.

Back to Top