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

GridDropDownColumn fixed size?

4 Answers 173 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 12 Nov 2008, 12:39 AM
I've added a GridDropDownColumn within a RadGrid and set  DropDownControlType="RadComboBox".
The binding and updating works fine.
It's just that the size of the drop down box is much bigger than the three or four items that are in the DropDown.

I tried converting it to a GridTemplateColumn and using a normal RadComboBox and this worked with the size of
the dropdown matching the number of items in the dropdown.

An example can be found at http://demos.telerik.com/aspnet/prometheus/Controls/Examples/Integration/GridEditors/DefaultCS.aspx?product=grid and clicking on the Title dropdown.

Thanks in advance.

Mike

4 Answers, 1 is accepted

Sort by
1
Shinu
Top achievements
Rank 2
answered on 12 Nov 2008, 04:15 AM
Hi Mike,

You can set the desired hieght and width to the ComboBox when the GridDropDownColumn is in edit mode as shown below.

ASPX:
 <telerik:GridDropDownColumn DataField="ProductName" DataSourceID="SqlDataSource1"  UniqueName="DropCol"  HeaderText="DropCol"  ListTextField="ProductName" ListValueField="ProductName"  ></telerik:GridDropDownColumn> 
     

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 radCombo = (RadComboBox)edititem["DropCol"].Controls[0]; 
            //to set height of the combobox dropdown according to item count
            radCombo.Height = Unit.Pixel(radCombo.Items.Count * 24); 
            //to set the combobox width
            radCombo.Width = Unit.Pixel(100); 
        } 
        
    } 

Thanks
Shinu
0
Mike
Top achievements
Rank 1
answered on 12 Nov 2008, 09:02 AM
Many thanks for the code.

Is this by design?

A normal RadComboBox within a GridTemplateColumn automatically adjusts its height to the number of entries
within it.

Thanks

Mike
0
Shinu
Top achievements
Rank 2
answered on 13 Nov 2008, 05:31 AM
Hi Mike,

As far as I know it is not possible to achieve this for a GridDropDownColumn during design time since the ComboBox will appear only in the edit mode. If you need to set it design time GridTemplateColumn is the alternative.

Shinu
0
Mike
Top achievements
Rank 1
answered on 13 Nov 2008, 08:40 AM
Shinu

Many thanks for your help, the code snippet you sent saved the day :-)

Where's the best place to report it as a suspected bug as I can't see why
one would want this as a default behavior plus also a RadComboBox within a GridTemplateColumn
doesn't exhibit this behavior.

I'ts probably only noticeable if you only have a few items in the dropdown.

Thanks again

Mike
Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Mike
Top achievements
Rank 1
Share this question
or