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

Column Size on Reorder

1 Answer 41 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 26 Dec 2008, 04:31 PM
When a user moves a column in the grid to a new location, it occupies the same space that the column that was in that spot takes up.  I am setting the HeaderStyle-Width property in the aspx for each GridBoundColumn. 

1 Answer, 1 is accepted

Sort by
0
Kevin Babcock
Top achievements
Rank 1
answered on 28 Dec 2008, 01:38 PM
Hello Ryan,

By default, when you reorder a column, it remains the same size (width) regardless of where it is placed in the column order. If you want to keep the columns sized relative to their position, you can use the RadGrid's ColumnsReorder event to set change their sizes. Here is an example of how you might handle that event:

protected void RadGrid1_ColumnsReorder(object source, Telerik.Web.UI.GridColumnsReorderEventArgs e) 
    var sourceWidth = e.Source.HeaderStyle.Width; 
    var targetWidth = e.Target.HeaderStyle.Width; 
    e.Source.HeaderStyle.Width = targetWidth; 
    e.Target.HeaderStyle.Width = sourceWidth; 



I hope this helps. Please let me know if you have any further questions.

Regards,
Kevin Babcock
Tags
Grid
Asked by
Ryan
Top achievements
Rank 1
Answers by
Kevin Babcock
Top achievements
Rank 1
Share this question
or