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

RadGrid Column Size in Edit Mode

2 Answers 276 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Matt Campbell
Top achievements
Rank 1
Matt Campbell asked on 19 Apr 2010, 07:53 PM

Consider the following definition for a column of a RadGrid:

 

<

 

 

telerik:GridDateTimeColumn DataField="p.AmendEffDate" DataType="System.DateTime" DataFormatString="{0:MM/dd/yyyy}" HeaderStyle-Width="100px" FooterStyle-Width="100px" ItemStyle-Width="100px" HeaderText="Amend Date" SortExpression="p.AmendEffDate" UniqueName="AmendEffDate" PickerType="DatePicker" ></telerik:GridDateTimeColumn>

 

 



It works wonderfully except that when in edit mode, the editing cell size overlaps other cells. Like the cell wants to be larger but since it is only 100px, it just overlaps the neighboring cell. There is no EditStyle-Width property or anything. I'm pretty sure it is doing this because the cell wants to include the Time in the data. However, in this case, there is no time data. How do I resolve this issue? I need the cell to be 100px. No larger.

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Apr 2010, 08:13 AM
Hello Matt,

One suggestion for avoiding cell overlapping appearance in edit mode, you can access the control in the particular column (when in EditMode) and set the width to required. Hope the following code will help you.

C#:

 
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)   
    {  
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)   
        {   
            GridEditableItem edititem = (GridEditableItem)e.Item;             
            RadDatePicker dPicker = (RadDatePicker)edititem["AmendEffDate"].Controls[0];   
            dPicker.Width = Unit.Pixel(100);   
        }   
    }  

Regards,
Shinu.
0
Matt Campbell
Top achievements
Rank 1
answered on 20 Apr 2010, 07:08 PM
That worked, thank you.
Tags
General Discussions
Asked by
Matt Campbell
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Matt Campbell
Top achievements
Rank 1
Share this question
or