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

[Solved] width of columns when using inplace editing

3 Answers 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
newbie
Top achievements
Rank 1
newbie asked on 30 Apr 2008, 07:36 PM
I have specified the width os some columns in my grid using the ItemStyle-Width property.
But when i click the edit button the columns expand and do not take the size I have specified.
I have 3 numeric columns and I want their size to be very small even in edit mode so that my text columns can have more space.

<

telerik:GridBoundColumn DataField="GateLength" HeaderText="Gate Length" SortExpression="GateLength"

UniqueName="GateLength" ItemStyle-Width="50px" >

</telerik:GridBoundColumn>

3 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 01 May 2008, 07:19 AM
Hello,

The size expansion is due to the textboxes rendered in the inline edit mode.
You can, however, dynamically alter the width, as shown in the code snippet below:

.cs
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
    {  
        if (e.Item is GridDataItem && e.Item.IsInEditMode)  
        {  
            GridDataItem dataItem = (GridDataItem)e.Item;  
            TextBox textBox = (TextBox)dataItem["CompanyName"].Controls[0];  
            textBox.Width = Unit.Pixel(40);  
        }   
    } 

I hope this information helps.

Greetings,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
newbie
Top achievements
Rank 1
answered on 01 May 2008, 05:22 PM
Thanks

That Helped.
0
Shinu
Top achievements
Rank 2
answered on 02 May 2008, 10:51 AM
Hi Newbie,

You can also set the Width of the TextBox in Percentage as shown below.

if (e.Item is GridDataItem && e.Item.IsInEditMode)   
        {   
            GridDataItem dataItem = (GridDataItem)e.Item;   
            TextBox textBox = (TextBox)dataItem["CompanyName"].Controls[0];   
            textBox.Width = Unit.Percentage(50);   
        }    
 


Shinu.

Tags
Grid
Asked by
newbie
Top achievements
Rank 1
Answers by
Yavor
Telerik team
newbie
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or