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

Column Width

3 Answers 84 Views
Grid
This is a migrated thread and some comments may be shown as answers.
rubenhak
Top achievements
Rank 1
rubenhak asked on 17 Feb 2010, 10:25 PM
Hi,

I'm using ASP.NET Ajax RadGrid. Is there a way to specify the column width programmatically from the code behind?
I need store column widths on the server side or cookies and further load those values, so the next time user opens the web page he get same columns size.

Thanks,
Ruben.

3 Answers, 1 is accepted

Sort by
0
Erwin Floresca
Top achievements
Rank 1
answered on 17 Feb 2010, 11:29 PM
you can use the column created event to specify the widths programmatically

VB.NET
 Protected Sub RadGrid1_ColumnCreated(sender As Object, e As Telerik.Web.UI.GridColumnCreatedEventArgs) Handles RadGrid1.ColumnCreated 
  If e.Column.UniqueName = "BirthDate" Then 
    Dim boundColumn As GridBoundColumn = CType(e.Column, GridBoundColumn) 
    boundColumn.HeaderStyle.Width = Unit.Pixel(100) 
    End If 
End Sub 'RadGrid1_ColumnCreated  

0
rubenhak
Top achievements
Rank 1
answered on 19 Feb 2010, 11:42 PM
Erwin,

I tried that and it does not make any difference. Column widths do not pick up the value i specify in ColumnCreated event. Also the widths are recalculated evenly when i change the side of the browser. Any ideas what is wrong with my grid?

Thanks,
Ruben.
0
Princy
Top achievements
Rank 2
answered on 20 Feb 2010, 05:50 AM
Hi,

Try setting the TableLayout="Fixed" for the MasterableView and set the widths in the ColumnCreated event . To know more on how to save column widths on a per user basis ,have a look at the link  Saving grid settings on a per user basis

Thanks,
Princy

Tags
Grid
Asked by
rubenhak
Top achievements
Rank 1
Answers by
Erwin Floresca
Top achievements
Rank 1
rubenhak
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or