GridDropDownColumn displays more space than needed for records

4 posts, 0 answers
  1. Rob T
    Rob T avatar
    44 posts
    Member since:
    Jul 2007

    Posted 01 Feb 2010 Link to this post


    Why does the GridDropDownColumn display larger than the count of items?


    Check the RadComboBox Columns example.  You see 5 records in the combo, but the combo drop down extends another 4 or 5 records further of empty white space.

    How do I fix this?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Feb 2010 Link to this post

    Hello Rob,

    You can set the dropdownlist height based on number of items (if it is less than a particular count) in list after accessing the control in ItemDataBound event. Here is an example for setting the dropdownlist height.

    CS:
     
       protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
        {       
            if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
            { 
                GridEditableItem editItem = (GridEditableItem)e.Item; 
                RadComboBox combo = (RadComboBox)editItem["dropdowncolumn"].Controls[0]; 
                int itemsCount = combo.Items.Count; 
                combo.Height = Unit.Pixel(itemsCount*12); 
            } 
        } 

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ben
    Ben avatar
    3 posts
    Member since:
    Jul 2015

    Posted 20 Jul 2015 in reply to Shinu Link to this post

    I'm running into this problem right now as well. Manually setting the height of the dropdownlist generally works but I've run into a ​case where it falls short. The drop down is getting populated with items where a few of them have enough text to cause the entry to line wrap, which ends up throwing off the resulting height of the dropdownlist. It's been a few years since this was posted. Is this still considered the best way to approach this problem in general and, if so, how would you recommend approaching this situation?
  5. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 23 Jul 2015 Link to this post

    Hello,

    If you are using the latest version of Telerik UI for ASP.NET AJAX and you encounter a problem with grid DropDownColumn it will be best to send us a sample project which we can test locally. Another option is to send us the problematic code so we can examine it and advice you further.

    Regards,
    Pavlina
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top