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

[Solved] Set column Width in %

1 Answer 453 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gagan Garg
Top achievements
Rank 1
Gagan Garg asked on 02 Nov 2009, 09:01 AM
Hi Telerik Guys,

I have a problem with assigning the column width in percentage for rad grid.

Can any one tell me how we set the column width in percentage for the grid columns.

Please gives your responses ASPS.


<

 

telerik:RadGrid ID="RadGrid" runat="server" Width="97%" DataSourceID="ObjectDataSource"

 

 

SkinID="NoPostBackOnRowSelect" GridLines="Vertical" AllowSorting="true" Style="margin: 0px 10px 0px 10px"

 

 

AutoGenerateColumns="False" OnItemDataBound="EmailPhoneRadGrid_ItemDataBound">

 

 

<MasterTableView DataKeyNames="phoneEmailID" DataSourceID="EmailPhoneObjectDataSource"

 

 

Frame="Void">

 

 

<NoRecordsTemplate>

 

No records to display !

 

</NoRecordsTemplate>

 

 

<Columns>

 

 

<telerik:GridBoundColumn DataField="Col1" HeaderText="Col1" SortExpression="Col1" UniqueName="Col1">

 

 

<HeaderStyle Font-Names="Trebuchet MS" Font-Size="14px" ForeColor="#3496b4" Width="48.5%" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="Col2" HeaderText="Col2" SortExpression="Col2"

 

 

UniqueName="Col2">

 

 

<HeaderStyle Font-Names="Trebuchet MS" Font-Size="14px" ForeColor="#3496b4" Width="15%" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="Col3" HeaderText="Col3"

 

 

SortExpression="Col3" UniqueName="Col3">

 

 

<HeaderStyle Font-Names="Trebuchet MS" Font-Size="14px" ForeColor="#3496b4" Width="15%" />

 

 

</telerik:GridBoundColumn>

 

 

</Columns>

 

 

</MasterTableView>

 

 

</telerik:RadGrid>


I am using above code. Is this correct or not. Please guide me.

Thanks in Advance.

 

1 Answer, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 02 Nov 2009, 10:48 PM
It seems as if you are declaring your Grid correctly but you could try this code-behind approach as well to see if you see any difference:
 
RadGrid1.Columns[0].ItemStyle.Width = Unit.Percentage(60); 


Tags
Grid
Asked by
Gagan Garg
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
Share this question
or