Dynamically created columns causes problem when column Display = False
We are Telerik v2010 Q1. When add a column with Dispay = false it hides the column, but there is the a large gap to the right of the grid e.g.
Before
|
ID |
Col 2 |
Col 3 |
|
|
|
|
After
|
Col 2 |
Col 3 |
<< GAP?! >> |
|
|
|
|
Extract
//id column
col = new GridBoundColumn();
//TODO: Setting col.Display = false causes a problem
this.uxResults.Columns.Add(col);
//now ammend properties
col.UniqueName = “ID"
col.Visible = true; //NB Note that Display is set to false!!
col.DataField = “ID”
col.HeaderText = "";
col.FilterListOptions = GridFilterListOptions.VaryByDataType;
//col.AllowFiltering = true;
//col.AllowSorting = true;
//col.ReadOnly = true;
col.Display = false;
| protected void RadGrid1_ItemInserted(object source, GridInsertedEventArgs e) |
| { |
| if (e.Exception != null) |
| { |
| Exception eex = e.Exception; |
| string msg; |
| if (ex.InnerException != null) msg = ex.InnerException.Message; |
| else msg = ex.Message; |
| RadGrid1.Controls.Add(new LiteralControl(string.Format("<span style='color:red'>{0}</span>", msg))); |
| e.ExceptionHandled = true; |
| } |
| } |
| protected void grdContactList_PreRender(object sender, EventArgs e) |
| { |
| foreach (GridGroupHeaderItem groupHeader in grdContactList.MasterTableView.GetItems(GridItemType.GroupHeader)) |
| { |
| string strtxt = groupHeader.DataCell.Text; // accessing the groupheader text |
| HyperLink link = new HyperLink(); |
| LinkButton hyperlnk = new LinkButton(); // creting new link |
| hyperlnk.Text = "mailto:" + strtxt; |
| groupHeader.DataCell.Controls.Clear(); |
| groupHeader.DataCell.Controls.Add(hyperlnk); |
| } |
| } |
| <telerik:RadBinaryImage runat="server" Visible="true" ID="binaryImage1" /> |
| <telerik:RadBinaryImage runat="server" Visible="false" ID="binaryImage2" /> |
| <asp:Button runat="server" ID="btn" OnClick="btn_Click" /> |
| protected void Page_Load(object sender, EventArgs e) |
| { |
| if (!Page.IsPostBack) |
| { |
| byte[] img = File.ReadAllBytes(@"d:\mydocuments\My Pictures\IMG_2787.JPG"); |
| binaryImage1.DataValue = img; |
| binaryImage2.DataValue = img; |
| } |
| } |
| protected void btn_Click(object sender, EventArgs e) |
| { |
| binaryImage1.Visible = !binaryImage1.Visible; |
| binaryImage2.Visible = !binaryImage2.Visible; |
| } |