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

[Solved] columns are shrinking on every postbacks in 826 version

4 Answers 127 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ildar
Top achievements
Rank 1
Ildar asked on 15 Sep 2009, 05:45 AM
AFTER updating the Telerik from version 701 to 826, 
(RadControls_for_ASP.NET_AJAX_2009_2_701_dev to
 RadControls_for_ASP.NET_AJAX_2009_2_826_dev)

on every postbacks the width of the columns is shrinking.
First time by 40%, then 30% and so on (I did not check up to what size).
That is, in a few postbacks, the grid becomes very very small.
If I remove from the setting: 

 

RadGrid1.ClientSettings.Resizing.AllowColumnResize = true

 

then no shrinking on postbacks as well as no resizing.
What is wrong with version 2009.2.826 ?

Ildar

4 Answers, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 15 Sep 2009, 07:08 PM
What browsers have you tested this in? And is there a bit of sample code you could provide to test out? I didn't manage to get this behavior on my end.
0
Ildar
Top achievements
Rank 1
answered on 15 Sep 2009, 07:11 PM
the brouther is IE8 with compatibility view on.
To provide code will take at least few hours.
0
Ildar
Top achievements
Rank 1
answered on 17 Sep 2009, 07:53 PM
Here is a code:

olaptest.aspx.cs file:

using System;  
using System.Data;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
using Telerik.Web.UI;  
 
namespace wdttest  
{  
 public partial class olaptest : System.Web.UI.Page  
 {  
  protected RadGrid RadGrid3 = new RadGrid();  
  DataTable datatable = new DataTable();  
  int columns=1;  
 
  protected void Page_Init(object sender, EventArgs e)  
  {  
   RadGrid3.ID = "RadGrid3"RadGrid3.AutoGenerateColumns = false;  
   RadGrid3.ClientSettings.Resizing.AllowColumnResize = true;    // ???  
  }  
 
  protected void Page_Load(object sender, System.EventArgs e)  
  {   
   if (!Page.IsPostBack) { Session["columns"] = columns = 1; }  
   columns = (int)Session["columns"];  
  }  
 
  protected void Page_PreRender(object sender, System.EventArgs e)  
  {  
   for (int i = 0; i < columns; i++)  
    {  
     datatable.Columns.Add("c" + i);  
     GridTemplateColumn gtc = new GridTemplateColumn();  
     gtc.HeaderText = ( i % 2 == 0 ) ? "UnitPrice" : "Quantity";   
     gtc.ItemTemplate   = new itemTemplate("c" + i);  
     RadGrid3.Columns.Add(gtc);  
    }  
 
   if (datatable.Columns.Count > 1) datatable.Rows.Add(new string[] { "2747", "3036" });  
   else                             datatable.Rows.Add(new string[] { "6055" });   
 
   RadGrid3.DataSource = datatable;  
   RadGrid3.DataBind();  
   PlaceHolder1.Controls.Add(RadGrid3);  
  }  
 
  // class template for item grid  
  private class itemTemplate : ITemplate  
  {  
   Label lc; private string colname;  
   public itemTemplate(string acolname) { colname = acolname; }  
   public void InstantiateIn(Control container)  
   {  
    lc = new Label();  
    lc.DataBinding += new EventHandler(lc_DataBinding);  
    container.Controls.Add(lc);  
   }  
   void lc_DataBinding(object sender, EventArgs e)  
   {  
    Label alc = (Label)sender;  
    GridDataItem container = (GridDataItem)alc.NamingContainer;  
    alc.Text = ((DataRowView)container.DataItem)[colname].ToString();  
   }  
  } // end of a class itemTemplate  
 
  protected void oneColumns_Click(object sender, EventArgs e)   
  { Session["columns"] = columns = 1; }  
  protected void twoColumns_Click(object sender, EventArgs e)   
  { Session["columns"] = columns = 2; }  
 } // end class  
}  // end namespace 

olaptest.aspx file:

<%@ Page Language="c#" CodeBehind="olaptest.aspx.cs" Inherits="wdttest.olaptest" %> 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > 
<html> 
<head id="shrinkingcolumns" runat="server"><title>Shrinking columns</title></head>  
<body>   
 <form id="Form1" method="post" runat="server">  
  <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
  Click "make a postback" a few times. Nothing will change.<br /> 
  Click "Two comumns" and click "make a postback" a few times.<br /> 
  The width of the columns is shrinking each times you are clicking.<br /> 
  <asp:PlaceHolder ID="PlaceHolder1"  runat="server" /><br /> 
  <asp:Button ID="makePostback" Text="make a postback" runat="server" /> 
  <asp:Button ID="twoColumns"   Text="Two columns"     runat="server" OnClick="twoColumns_Click" /> 
  <asp:Button ID="oneColumns"   Text="One column"      runat="server" OnClick="oneColumns_Click" /> 
 </form> 
</body> 
</html> 

I have tested on IE8 and Firefox 3.5.

 

 

 

 

0
Dimo
Telerik team
answered on 18 Sep 2009, 04:58 PM
Hi Ildar,

We recommend adding RadGrid columns at runtime in Page_Load or earlier. Moreover, template columns must be added in Page_Init.

Please rework your implementation to comply with the RadGrid programmatic creation guidelines below and let us know if you need further assistance.

http://www.telerik.com/help/aspnet-ajax/grdprogrammaticcreation.html

As for the column resizing change, yes, we made a change, related to the MasterTableView's TableLayout, which is related to the ClientSettings.Resizing.ClipCellContentOnResize property. Try setting that to "false".

Best wishes,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Ildar
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
Ildar
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or