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

Radgrid - GridBoundColumn - Inline editing - Itemstyle-width not working

6 Answers 742 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Suzy
Top achievements
Rank 2
Suzy asked on 27 Apr 2015, 09:54 AM

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

Sort by
0
Pavlina
Telerik team
answered on 28 Apr 2015, 08:12 AM
Hello,

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.

 
0
Suzy
Top achievements
Rank 2
answered on 28 Apr 2015, 09:44 AM

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

 

0
Pavlina
Telerik team
answered on 28 Apr 2015, 03:45 PM
Hi,

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.

 
0
Suzy
Top achievements
Rank 2
answered on 29 Apr 2015, 08:15 AM

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

0
Accepted
Pavlina
Telerik team
answered on 04 May 2015, 09:10 AM
Hello,

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 If
End Sub

Additionally 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.

 
0
Suzy
Top achievements
Rank 2
answered on 05 May 2015, 08:30 AM

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);

Tags
Grid
Asked by
Suzy
Top achievements
Rank 2
Answers by
Pavlina
Telerik team
Suzy
Top achievements
Rank 2
Share this question
or