Resizing Dropdown ComboBox

3 posts, 0 answers
  1. Rich
    Rich avatar
    31 posts
    Member since:
    May 2011

    Posted 25 Jul 2011 Link to this post

    I have found, and tried, some of the solutions for this problem in this forum.  I'm somewhat new to Telerik controls, and I'm sure this is part of my problem, but what I want to do should not be this difficult! 

    I need to limit the height of a combobox when click (dropdown).
    Here is the code (copied right from a lising on this forum):
    //This function limits the size of the combo box dropdown size.
        function OnClientDropDownOpeningHandler(sender, eventArgs)
        //set the max allowed height of the combo 
        var MAX_ALLOWED_HEIGHT = 140;
        //this is the single item's height 
        var SINGLE_ITEM_HEIGHT = 22;
        //var calculatedHeight = ctlUserCombo.get_items().get_count() * SINGLE_ITEM_HEIGHT;
        var dropDownDiv = sender.get_dropDownElement();
        if (calculatedHeight > MAX_ALLOWED_HEIGHT) 
            setTimeout (
                function () {
           = MAX_ALLOWED_HEIGHT + "px"; 
                }, 20
            setTimeout (
                function ()
           = calculatedHeight + "px"; 
                }, 20
    The first time I tried this I got a runtime error when I tried to calculate calculatedHeight.  The error was that the method was "Object doesn't support this property or method".  So I just put a hard value in there to see if that would work...NOPE, go the same error on the line trying to get the dropDownDiv.

    I also tried sending in the name of the control directly instead of using the SENDER parameter...same thing happens. 

    This page is used in several other applications, and some of them cut off the bottom of the dropdown.  All I need is a way to limit the height so that doesn't happen and the users can scroll to the bottom.  Why is this so hard?  In the web config it appears the controls are from Q3 2008, and that cannot change. 

    Can anyone see what the heck I'm doing wrong and/or point me to some documentation that actually works?

    Thanks from a VERY frustrated developer.

  2. Najid Hanif
    Najid Hanif avatar
    92 posts
    Member since:
    Jul 2011

    Posted 25 Jul 2011 Link to this post

    Rich, I am a total newb myself and maybe I don't understand what you are trying to do but if all you need to do is set the height, you can do that with a RadComboBox property.

    <telerik:RadComboBox runat="server" ID="RadComboBox1" Height="140px"
                         Width="750px" >

  3. Thad
    Thad avatar
    106 posts
    Member since:
    Sep 2010

    Posted 25 Jul 2011 Link to this post


    You want to use the MaxHeight property.

    <telerik:RadComboBox ID="RadComboBox1" runat="server" MaxHeight="140px">

    Height will fix the height at 140px, but it appears you want it to be shorter than 140px if there are fewer records in it.

    Hope that helps!
Back to Top