This is an FYI. I created a support ticket for this issue and thought it would be helpful to post the work-around for others.
I was using the RadGrid with the header context menu enabled and using a web service as the data source. The issue I had was with hiding/showing columns.
1. Use header context menu to hide column.
2. Use menu to show hidden column.
3. Go to another page.
4. The shown column is again hidden.
Here's the fix that was provided from Telerik.
ASPX
Web Service (for reference)
I was using the RadGrid with the header context menu enabled and using a web service as the data source. The issue I had was with hiding/showing columns.
1. Use header context menu to hide column.
2. Use menu to show hidden column.
3. Go to another page.
4. The shown column is again hidden.
Here's the fix that was provided from Telerik.
ASPX
| <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication4._Default" %> |
| <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head runat="server"> |
| <title></title> |
| <script type="text/javascript"> |
| function RadGrid1_Command(sender, args) { |
| var mtv = args.get_tableView(); |
| for (var i = 0, j = mtv.get_columns().length; i < j; i++) { |
| if (mtv.get_columns()[i].Display) |
| mtv.get_columns()[i].Display = null; |
| } |
| } |
| </script> |
| </head> |
| <body> |
| <form id="form1" runat="server"> |
| <div> |
| <asp:ScriptManager ID="ScriptManager" runat="server" AsyncPostBackTimeout="1000" |
| ScriptMode="Release"> |
| </asp:ScriptManager> |
| <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True" |
| AllowMultiColumnSorting="False" AutoGenerateColumns="False" Width="100%" AllowMultiRowSelection="True" |
| Height="565px" PageSize="20" ShowStatusBar="True" BorderWidth="1px" GridLines="Vertical"> |
| <MasterTableView EnableHeaderContextMenu="true"> |
| <Columns> |
| <telerik:GridBoundColumn DataField="NUMBERS" HeaderText="NUMBERS" UniqueName="NUMBERS"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="LETTERS" HeaderText="LETTERS" UniqueName="LETTERS"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="WORDS" HeaderText="WORDS" UniqueName="WORDS"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| </MasterTableView> |
| <ClientSettings AllowColumnsReorder="true" ColumnsReorderMethod="Reorder" ReorderColumnsOnClient="true"> |
| <ClientEvents OnCommand="RadGrid1_Command" /> |
| <Scrolling AllowScroll="True" UseStaticHeaders="True" /> |
| <Resizing AllowColumnResize="true" /> |
| <Selecting AllowRowSelect="true" /> |
| <DataBinding Location="~/TestService.asmx" SelectMethod="GetData"> |
| </DataBinding> |
| </ClientSettings> |
| </telerik:RadGrid> |
| </div> |
| </form> |
| <script type="text/javascript"> |
| var RadGrid1_ClientId = "<%= RadGrid1.ClientID %>"; |
| </script> |
| </body> |
| </html> |
Web Service (for reference)
| [WebService(Namespace = "http://tempuri.org/")] |
| [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] |
| [ScriptService] |
| [System.ComponentModel.ToolboxItem(false)] |
| public class TestService : System.Web.Services.WebService { |
| [WebMethod(EnableSession = true)] |
| public Dictionary<string, object> GetData(int startRowIndex, int maximumRows, List<GridSortExpression> sortExpression, List<GridFilterExpression> filterExpression) { |
| Dictionary<string, object> data = new Dictionary<string, object>(); |
| List<object> rows = new List<object>(); |
| for (int i = 0; i < 100; i++) { |
| rows.Add(new { |
| NUMBERS = i, |
| LETTERS = "A", |
| WORDS = "One" |
| }); |
| rows.Add(new { |
| NUMBERS = i, |
| LETTERS = "B", |
| WORDS = "Two" |
| }); |
| rows.Add(new { |
| NUMBERS = i, |
| LETTERS = "C", |
| WORDS = "Three" |
| }); |
| rows.Add(new { |
| NUMBERS = i, |
| LETTERS = "D", |
| WORDS = "Four" |
| }); |
| rows.Add(new { |
| NUMBERS = i, |
| LETTERS = "E", |
| WORDS = "Five" |
| }); |
| rows.Add(new { |
| NUMBERS = i, |
| LETTERS = "F", |
| WORDS = "Six" |
| }); |
| } |
| data.Add("Count", rows.Count); |
| int numElements = maximumRows; |
| if (maximumRows > (rows.Count - startRowIndex)) { |
| maximumRows = rows.Count - startRowIndex; |
| } |
| var tmpData = rows.GetRange(startRowIndex, maximumRows); |
| data.Add("Data", tmpData); |
| return data; |
| } |
| } |