Hi,
I have radgrid, with inline editing. Problem is that the edit field is not set to 80%. see image in attachment.
Below is the setting of the GridBoundColumn :
<telerik:GridBoundColumn DataField="Description" HeaderStyle-Width="50%" ItemStyle-Width="80%" FilterControlWidth="80%" HeaderText="Description" SortExpression="Description" UniqueName="Description" ShowFilterIcon="false" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true"> <ColumnValidationSettings EnableRequiredFieldValidation="true"> <RequiredFieldValidator Text="<img src='/CMIT/Images/Warning.gif' border='0'>" Display="Dynamic" ToolTip="Description is required." ErrorMessage="-Description is required." ></RequiredFieldValidator> </ColumnValidationSettings></telerik:GridBoundColumn>How can I make the edit column wider?
Kind regard
Suzy
6 Answers, 1 is accepted
Try using HeaderStyle-Width to set column width instead of ItemStyle-Width and let me know about the result.
Regards,
Pavlina
Telerik
See What's Next in App Development. Register for TelerikNEXT.
The headerstyle-width is used to define the width within the radgrid.
I have 3 fields :
<Columns> <telerik:GridBoundColumn DataField="FieldName" HeaderStyle-Width="25%" HeaderText="Field" UniqueName="FieldName" > </telerik:GridBoundColumn> <telerik:GridTemplateColumn HeaderText="Type" HeaderStyle-Width="25%" UniqueName="FieldType" DataField="FieldType"> <ItemTemplate><%# CartaMundi.BusinessLogic.QValues.GetDescription("FieldType","*D","",DataBinder.Eval(Container, "DataItem.FieldType"),"")%></ItemTemplate> <EditItemTemplate> <telerik:RadComboBox runat="server" ID="ddlFieldType" Width="80%" ></telerik:RadComboBox> </EditItemTemplate> </telerik:GridTemplateColumn> <telerik:GridBoundColumn DataField="Description" HeaderStyle-Width="50%" ItemStyle-Width="80%" HeaderText="Description" UniqueName="Description" > </telerik:GridBoundColumn></Columns>The first and second field use each 25%, the last field uses 50% of the available space.
Kind regards
Suzy
I have noticed that you have not removed ItemStyle-Width from the Description column yet. Remove it and leave only HeaderStyle-Width. In case you want the input in edit mode to be wider you can access it OnItemDataBound and change its width manually.
Regards,
Pavlina
Telerik
See What's Next in App Development. Register for TelerikNEXT.
Hi Pavlina,
I tried that but I think the code is wrong :
GridEditableItem editItem = (GridEditableItem)e.Item;TableCell Description = (TableCell)editItem["Description"];Description.Width = new Unit(100,UnitType.Percentage);How do I do that?
Kind regards
Suzy
Try with the following code:
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs) If TypeOf e.Item Is GridEditableItem AndAlso TryCast(e.Item, GridEditableItem).IsInEditMode Then Dim item As GridEditableItem = TryCast(e.Item, GridEditableItem) Dim txt As TextBox = DirectCast(item("Description").Controls(0), TextBox) 'accessing GridBoundColumn txt.Width = Unit.Pixel(50) 'you can set the column with in Percentage End IfEnd SubAdditionally for more information about accessing cells and rows you can refer to the article below:
http://www.telerik.com/help/aspnet-ajax/grid-accessing-cells-and-rows.html
Regards,
Pavlina
Telerik
See What's Next in App Development. Register for TelerikNEXT.
Thank you Pavlina.
For the ones who need it, below the code in C# :
GridEditableItem editItem = (GridEditableItem)e.Item;TextBox txtDescription = (TextBox)editItem["Description"].Controls[0];txtDescription.Width = Unit.Percentage(80);