I've a problem with showing and hiding a column via an ajax request. When I set the column's Visible property to false, the column is hidden, but when set back to true the column does not reappear.
Try the following page
ASPX
C#
When you click the fire button an ajax request is fired and the second column's visiblity is toggled.
The first click hides the column, which is fine, but the second click doesn't show it again..
Any ideas?
Thanks,
Stephen
Try the following page
ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
<head runat="server"> |
<title>Untitled Page</title> |
</head> |
<body> |
<script type="text/javascript"> |
function firePostBack(arg) |
{ |
$find('<%=ajaxManager.ClientID %>').ajaxRequest(arg); |
} |
</script> |
<form id="form1" runat="server"> |
<asp:ScriptManager ID="ScriptManager1" runat="server" /> |
<div> |
<telerik:RadAjaxManager OnAjaxRequest="ajaxManager_AjaxRequest" ID="ajaxManager" runat="server"> |
<AjaxSettings> |
<telerik:AjaxSetting AjaxControlID="ajaxManager"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl ControlID="grid" /> |
</UpdatedControls> |
</telerik:AjaxSetting> |
</AjaxSettings> |
</telerik:RadAjaxManager> |
</div> |
<telerik:RadGrid runat="server" ID="grid" OnNeedDataSource="grid_NeedDataSource"> |
<MasterTableView AutoGenerateColumns="false"> |
<Columns> |
<telerik:GridBoundColumn DataField="col1" HeaderText="Col1"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="col2" HeaderText="Col1"></telerik:GridBoundColumn> |
</Columns> |
</MasterTableView> |
</telerik:RadGrid> |
<a href="#" onclick="firePostBack('1');return false;">Fire</a> |
</form> |
</body> |
</html> |
C#
using System; |
using System.Data; |
using System.Configuration; |
using System.Web; |
using System.Web.Security; |
using System.Web.UI; |
using System.Web.UI.WebControls; |
using System.Web.UI.WebControls.WebParts; |
using System.Web.UI.HtmlControls; |
using System.Net; |
using System.Collections.Generic; |
using Telerik.Web.UI; |
public partial class _Default : System.Web.UI.Page |
{ |
protected void grid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) |
{ |
DataTable table = new DataTable(); |
table.Columns.Add("col1"); |
table.Columns.Add("col2"); |
table.Rows.Add("data1", "data2"); |
table.Rows.Add("data3", "data4"); |
table.Rows.Add("data5", "data6"); |
grid.DataSource = table; |
} |
protected void ajaxManager_AjaxRequest(object sender, AjaxRequestEventArgs e) |
{ |
grid.Columns.FindByUniqueName("col2").Visible = !grid.Columns.FindByUniqueName("col2").Visible; |
} |
} |
When you click the fire button an ajax request is fired and the second column's visiblity is toggled.
The first click hides the column, which is fine, but the second click doesn't show it again..
Any ideas?
Thanks,
Stephen