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

Grid columns are no longer proportionally sized

2 Answers 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jay
Top achievements
Rank 1
Jay asked on 30 Apr 2010, 10:47 PM
I just upgraded from 2009 to the latest 2010, and am using the RadGrid. Previously, the columns were being sized "proportionally" ... columns with more text are wider than columns with less text. This was done automatically by the grid control. Now it seems that the grid column widths are all the same size. How do I configure the grid to behave like it used to ... to auto size column width depending on the data.
Thanks!

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 03 May 2010, 08:23 AM
Hello Jay,

Set the TableLayout property of GridTableView as "Auto" which in turn sets the column width to the widest unbreakable content in the column cells.


Regards,
Princy.
0
Jay
Top achievements
Rank 1
answered on 03 May 2010, 09:03 PM
The TableLayout seems to work UNLESS the Resizing-AllowColumnResize="true" attribute is set (which is a requirement in my application). Is there another attribute so that it works with the Resizing-AllowColumnResize="true"? Thanks!

Here is my ASPX:
<telerik:RadGrid runat="server" ID="RadGrid1"
AutoGenerateColumns="False"
OnNeedDataSource="RadGrid1_NeedDataSource"
Width="100%"
>                       
 <ClientSettings Resizing-AllowColumnResize="true" >
 </ClientSettings>
 <MasterTableView TableLayout="Auto">
  <Columns>
   <telerik:GridBoundColumn DataField="C1" HeaderText="C1">
   </telerik:GridBoundColumn>
   <telerik:GridBoundColumn DataField="C2" HeaderText="C2">
   </telerik:GridBoundColumn>
   <telerik:GridBoundColumn DataField="C3" HeaderText="C3">
   </telerik:GridBoundColumn>
  </Columns>
 </MasterTableView>
</telerik:RadGrid>

and the code behind ...

 public class MyObj
 {
  public string _innerText = "";

  public MyObj()
  {
  }

  public string C1
  {
   get
   {
    return "col1";
   }
  }

  public string C2
  {
   get
   {
    return "col2";
   }
  }

  public string C3
  {
   get
   {
    return "This is a really long colum. This is more data for my really long colum.";
   }
  }
 }

 protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
 {
  ArrayList list = new ArrayList();
  list.Add(new MyObj());
  list.Add(new MyObj());
  list.Add(new MyObj());
  this.RadGrid1.DataSource = list;
 }

Tags
Grid
Asked by
Jay
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jay
Top achievements
Rank 1
Share this question
or