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

How to Dynamically Set RadGrid Column Width?

6 Answers 1579 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Deekshith
Top achievements
Rank 1
Deekshith asked on 13 Apr 2014, 04:00 AM
Hi All,
Is their anybody knows how to Dynamically set the RadGrid Column width??

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 14 Apr 2014, 07:05 AM
Hi Deekshith,

You can use the PreRender event of the RadGrid to set the column width of a RadGrid.

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
  RadGrid1.MasterTableView.GetColumn("ColumnUniqueName").HeaderStyle.Width = Unit.Pixel(100); 
}

Thanks,
Princy
0
Deekshith
Top achievements
Rank 1
answered on 14 Apr 2014, 09:53 AM
Thank You :)
0
Deekshith
Top achievements
Rank 1
answered on 21 Apr 2014, 10:45 AM
Hi Princy is their any way is their to do the same thing in .aspx?
0
Princy
Top achievements
Rank 2
answered on 21 Apr 2014, 12:47 PM
Hi Deekshith,

You can set the Width of the column in aspx as follows:

ASPX:
<telerik:GridBoundColumn UniqueName="ID" DataField="ID" HeaderText="ID">
    <HeaderStyle Width="200px" />
</telerik:GridBoundColumn>

Thanks,
Princy
0
SABITHA
Top achievements
Rank 1
answered on 06 Feb 2015, 07:01 AM
In my case the grid has to populate the columns in the conditional basis .  In some cases it will be total of 5 columns and in the other case it will be columns of the total 15columns . Is there any way to set the widhth of all the grid columns to say 100px from the server side code for example say pre-render method.
0
Eyup
Telerik team
answered on 11 Feb 2015, 09:54 AM
Hello Sabitha,

The PreRender event handler is raised a bit late, therefore, you can use the Load or ColumnCreated events if you are using AutogeneratedColumns. In addition, you can check the following approach:
http://www.telerik.com/help/aspnet-ajax/grid-gridcolumn-resizetofit.html

Hope this helps.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
Deekshith
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Deekshith
Top achievements
Rank 1
SABITHA
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or