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

Resizing Dropdown ComboBox

2 Answers 96 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Rich
Top achievements
Rank 1
Rich asked on 25 Jul 2011, 07:39 PM
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 () {
                dropDownDiv.firstChild.style.height = MAX_ALLOWED_HEIGHT + "px"; 
            }, 20
        );                
    
    else 
    
        setTimeout (
 
            function ()
            {
                dropDownDiv.firstChild.style.height = 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.

Rich

2 Answers, 1 is accepted

Sort by
0
Najid Hanif
Top achievements
Rank 2
answered on 25 Jul 2011, 09:21 PM
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" >

0
Thad
Top achievements
Rank 2
answered on 25 Jul 2011, 09:58 PM
Rich,

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!
Thad
Tags
ComboBox
Asked by
Rich
Top achievements
Rank 1
Answers by
Najid Hanif
Top achievements
Rank 2
Thad
Top achievements
Rank 2
Share this question
or