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

Why the the height of dorpdown item is so height?

3 Answers 112 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jin
Top achievements
Rank 1
Jin asked on 03 Sep 2012, 09:10 AM
When I edit a record with a RadCombox control in RadGrid, the height of dropdown item is so height(in attached image). Normaill, if the RadCombox bound two record, it should only show the height of two record. Don't know why it sill have so many blank space?

My Code is:
 protected void RadGridFunction_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item is GridEditableItem)
            {
                GridEditableItem editedItem = e.Item as GridEditableItem;
                if ((e.Item as GridEditableItem).IsInEditMode)
                {
                    GridEditManager editMan = editedItem.EditManager;

                    GridDropDownListColumnEditor editor = editMan.GetColumnEditor("RuleType") as GridDropDownListColumnEditor;
                    RadComboBox ddl = (RadComboBox)editedItem["RuleType"].Controls[0];
                    ddl.Width = Unit.Pixel(100);


                    ddl.Items.Add(new RadComboBoxItem("dd1"));
                    ddl.Items.Add(new RadComboBoxItem("dd2"));                 
                }
            }           
        }

 <telerik:GridDropDownColumn DataField="RuleType" UniqueName="RuleType"
                                    HeaderText="Rule Type" ItemStyle-Width="100px">
                                    <FilterTemplate>
                                        <telerik:RadComboBox runat="server" Width="100px" ID="RadComboBoxRuleType" AutoPostBack="true">                                                                                   
                                        </telerik:RadComboBox>
                                    </FilterTemplate>
                                </telerik:GridDropDownColumn>

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 03 Sep 2012, 09:22 AM
Hi,

Try setting the height of the RadComboBox as shown below.

C#:
protected void RadGridFunction_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridEditableItem)
        {
           . . .
           . . .
 
            ddl.Width = Unit.Pixel(100);
            ddl.Height = Unit.Pixel(20*2);
 
           ddl.Items.Add(new RadComboBoxItem("dd1"));
           ddl.Items.Add(new RadComboBoxItem("dd2"));
         }
}

Thanks,
Shinu.
0
Jin
Top achievements
Rank 1
answered on 03 Sep 2012, 09:38 AM
Hi Shinu,

Thanks for you code and it works fine. Only my concern is why it need to add that line code to compute the height instead of auto compute the height?
0
Shinu
Top achievements
Rank 2
answered on 04 Sep 2012, 05:07 AM
Hi Jin,

Try setting the MaxHeight property of the RadComboBox.It allows the height of the dropdown to vary depending on the number of items. If the number of items is large - the height will not exceed the MaxHeight value.

C#:
ddl.MaxHeight = 150;

Thanks,
Shinu.
Tags
Grid
Asked by
Jin
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jin
Top achievements
Rank 1
Share this question
or