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

[Solved] Set size of inline editing controls?

1 Answer 185 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 15 Jun 2009, 08:07 PM
Is there any way to set the size of the textboxes/comboboxes/etc used in inline editing? I have a RadGrid inside a RadPane, and when the edit command column is used the grid becomes wider than the pane it's in, necessitating horizontal scrolling.  This is because most of the inputs are about twice as wide as they actually need to be for the data they contain.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 Jun 2009, 06:54 AM
Hi Chris,

One suggestion is accessing the controls code behind to set the width when in EditMode.

ASPX:
 
 
 
<Columns> 
    <telerik:GridDropDownColumn DataField="CompanyName" HeaderText="Align" UniqueName="Combo" DataSourceID="SqlDataSource1" ListTextField="CompanyName" ListValueField="CompanyName" 
        DropDownControlType="RadComboBox" EnableEmptyListItem="false"
    </telerik:GridDropDownColumn> 
 
    <telerik:GridTemplateColumn UniqueName="TempColumn"
        <ItemTemplate> 
            Country 
        </ItemTemplate> 
        <EditItemTemplate> 
            <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
            </asp:DropDownList> 
        </EditItemTemplate> 
    </telerik:GridTemplateColumn> 
      . . . 
</Columns> 

CS:
 
 
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    if(e.Item is GridDataItem && e.Item.IsInEditMode) 
    { 
        GridDataItem item = (GridDataItem)e.Item; 
        RadComboBox combo = (RadComboBox)item["Combo"].Controls[0]; // Get the RadCombobox 
        combo.Width = Unit.Pixel(80);  // Set width 
        DropDownList dropdown = (DropDownList)item.FindControl("DropDownList1"); // Get the dropdown 
        dropdown.Width = Unit.Pixel(80);  // Set width 
    } 

Another option is by setting the TableLayout property of grid MasterTableView to Fixed in order to show fixed width for radgrid.

-Shinu.
Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or