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

Radgrid Popup EditMode Field Width Issue

4 Answers 226 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 04 Mar 2009, 09:16 AM
I have a popup edit form that is autogenerated, the only issue i have is that the drop down list fields are not wide enough(actually the text is mashed and unreadable when viewing the list after hitting the down arrow).  I guess I am looking for a way to make all 30 controls on the pop up form bigger. 

Thanks in advance for the help.

John

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 04 Mar 2009, 10:35 AM
Hello John,

You can either access the controls in the EditForm and set its width as shown below:
cs:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode) 
        { 
            GridEditFormItem editFormItem = (GridEditFormItem)e.Item; 
            foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns) 
            { 
                if (col.ColumnType == "GridBoundColumn"
                { 
                    ((TextBox)editFormItem[col.UniqueName].Controls[0]).Width = Unit.Pixel(200); 
                } 
                if (col.ColumnType == "GridTemplateColumn"
                { 
                    DropDownList ddl = (DropDownList)editFormItem.FindControl("DropDownListControlID"); 
                    ddl.Width = Unit.Pixel(200); 
                } 
            } 
        } 
    } 

OR
You can use column editors and set the desired styles for the column editors as described in the help document below:
Declarative style editors

Thanks
Princy.
0
John
Top achievements
Rank 1
answered on 04 Mar 2009, 03:03 PM
Princy,

Thank so much for the fast response.  The code worked great for the GridBoundColumns on the form they all resized.  I am still having trouble getting the GridDropDownColumn fields and the GridDateTimeColumn fields to resize.  Can you please point me to a code example for those column types?

Thanks,
John.
0
Accepted
Princy
Top achievements
Rank 2
answered on 05 Mar 2009, 06:02 AM
Hello John,

You can try out the following code to set the width of the DropDownList and DatePicker for DropDownColumns or DateTimeColumns of your grid:
cs:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
      if (e.Item is GridEditFormItem && e.Item.IsInEditMode) 
        { 
            GridEditFormItem editFormItem = (GridEditFormItem)e.Item; 
            
                if (col.ColumnType == "GridDropDownColumn") 
                { 
                    DropDownList ddl = (DropDownList)editFormItem["DropDownColumn"].Controls[0]; 
                    ddl.Width = Unit.Pixel(500); 
                } 
 
                if (col.ColumnType == "GridDateTimeColumn") 
                { 
                    RadDatePicker datepicker = (RadDatePicker)editFormItem["DateTimeColumn"].Controls[0]; 
                    datepicker.Width = Unit.Pixel(500); 
                }             
        } 
     } 

Thanks
Princy.
0
John
Top achievements
Rank 1
answered on 06 Mar 2009, 04:16 PM

Thanks Princy for the help I got it to work.  Here's what the final code was to get it working.  Thanks again!!!

protected void RGrd_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)  
    {  
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode)  
        {  
            GridEditFormItem editFormItem = (GridEditFormItem)e.Item;  
            foreach (GridColumn col in RGrd.MasterTableView.RenderColumns)  
            {  
                if (col.ColumnType == "GridBoundColumn")  
                {  
                    ((TextBox)editFormItem[col.UniqueName].Controls[0]).Width = Unit.Pixel(575);  
                }  
                if (col.ColumnType == "GridDropDownColumn")  
                {  
                    RadComboBox ddl = (RadComboBox)editFormItem[col.UniqueName].Controls[0];  
                    ddl.Width = Unit.Pixel(575);  
                }  
 
                if (col.ColumnType == "GridDateTimeColumn")  
                {  
                    RadDatePicker datepicker = (RadDatePicker)editFormItem[col.UniqueName].Controls[0];  
                    datepicker.Width = Unit.Pixel(575);  
                }               
 
            }  
        }   
Tags
Grid
Asked by
John
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
John
Top achievements
Rank 1
Share this question
or