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

Header Context Menu - Columns not hiding when checked

3 Answers 110 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lee Malo
Top achievements
Rank 1
Lee Malo asked on 10 Mar 2010, 11:17 PM
I have a RadGrid with columns being added programatically in the page_load. Everything works but if I check a column the menu disappears and the column doesnt hide.
Any suggestions?

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 11 Mar 2010, 08:50 AM
Hi,

Could you make sure that you are following a similar approach to enable the Header Context Menu.This is working fine on my end

C#
 protected void Page_Load(object sender, EventArgs e) 
    { 
      if ( !IsPostBack ) 
     { 
       RadGrid1.DataSourceID = "SqlDataSource1"
       RadGrid1.MasterTableView.DataKeyNames = new string[] { "CustomerID" }; 
       RadGrid1.Width = Unit.Percentage(98); 
       RadGrid1.PageSize = 5; 
       RadGrid1.AllowPaging = true
       RadGrid1.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric; 
       RadGrid1.AutoGenerateColumns = false
       RadGrid1.Skin = "Web20"
       //Add Customers table 
       RadGrid1.MasterTableView.PageSize = 15; 
       RadGrid1.MasterTableView.EnableHeaderContextMenu = true
       RadGrid1.MasterTableView.Width = Unit.Percentage(100); 
       GridBoundColumn boundColumn; 
       boundColumn = new GridBoundColumn(); 
       RadGrid1.MasterTableView.Columns.Add(boundColumn);                
       boundColumn.DataField = "CustomerID"
       boundColumn.HeaderText = "CustomerID"
       boundColumn = new GridBoundColumn(); 
       RadGrid1.MasterTableView.Columns.Add(boundColumn); 
       boundColumn.DataField = "ContactName"
       boundColumn.HeaderText = "Contact Name"
        
      } 
   } 

Princy
0
Lee Springthorpe
Top achievements
Rank 1
answered on 11 Mar 2010, 05:56 PM
Hi,

I have just come across the same problem, just upgraded to 2010.1.309.35 from 2009.3.1103.35.  Worked fine in the older version, in the new version when clicked on the item in the menu nothing happens and the menu closes.

<!-- HTML -->
    <telerik:RadGrid ID="RadOrders" runat="server" AllowPaging="True"  PageSize="30">
    </telerik:RadGrid>

<!--Code Behind-->
            RadOrders.DataSource = somedatasource;
            RadOrders.MasterTableView.DataKeyNames = new string[] { "OrderID" };

            // RadGrid Styles
            RadOrders.Width = Unit.Percentage(100);
            RadOrders.PageSize = 10;
            RadOrders.AllowPaging = true;
            RadOrders.AutoGenerateColumns = false;
            RadOrders.Skin = "Default";
            RadOrders.EnableHeaderContextMenu = true;

            RadOrders.MasterTableView.Width = Unit.Pixel(100);
            RadOrders.ClientSettings.Scrolling.AllowScroll = true;
            RadOrders.ClientSettings.Scrolling.UseStaticHeaders = true;
            RadOrders.ClientSettings.Scrolling.SaveScrollPosition = true;
            RadOrders.ClientSettings.EnableRowHoverStyle = true;
            RadOrders.ClientSettings.AllowColumnHide = true;

            // RadGrid Columns
            GridBoundColumn boundColumn = new GridBoundColumn();
            boundColumn.DataField = "Style";
            boundColumn.HeaderText = "Style";
            boundColumn.HeaderStyle.Width = boundColumn.ItemStyle.Width = Unit.Pixel(120);
            RadOrders.MasterTableView.Columns.Add(boundColumn);
            boundColumn = new GridBoundColumn();
            boundColumn.DataField = "PO";
            boundColumn.HeaderText = "P.O.";
            boundColumn.HeaderStyle.Width = boundColumn.ItemStyle.Width = Unit.Pixel(60);
            RadOrders.MasterTableView.Columns.Add(boundColumn);
            boundColumn = new GridBoundColumn();
            boundColumn.DataField = "Cons";
            boundColumn.HeaderText = "Docket";
            boundColumn.HeaderStyle.Width = boundColumn.ItemStyle.Width = Unit.Pixel(60);
            RadOrders.MasterTableView.Columns.Add(boundColumn);
            boundColumn = new GridBoundColumn();
            boundColumn.DataField = "Splr";
            boundColumn.HeaderText = "Supplier";
            boundColumn.HeaderStyle.Width = boundColumn.ItemStyle.Width = Unit.Pixel(200);
            RadOrders.MasterTableView.Columns.Add(boundColumn);
            boundColumn = new GridBoundColumn();
            boundColumn.DataField = "Qty";
            boundColumn.HeaderText = "Qty.";
            boundColumn.HeaderStyle.Width = boundColumn.ItemStyle.Width = Unit.Pixel(60);
            RadOrders.MasterTableView.Columns.Add(boundColumn);
            boundColumn = new GridBoundColumn();
            boundColumn.DataField = "Description";
            boundColumn.HeaderText = "Description";
            boundColumn.ItemStyle.Width = boundColumn.HeaderStyle.Width = Unit.Pixel(250);
            RadOrders.MasterTableView.Columns.Add(boundColumn);

            RadOrders.DataBind();


Not recieving any javascript errors, could i be missing any thing that has been added to the new version?
0
Tsvetoslav
Telerik team
answered on 12 Mar 2010, 07:46 AM
Hello Lee,

Could you take a look at the help article and our online examples on the programmatic creation of the grid. If you are creating the grid on Page_Load you need to be adding the columns to the MasterTableView first and then set their properties in order for their ViewState to be tracked correctly. In addition, you should remove the DataBind() call from the grid-creation code as it is not needed as explained in the online examples on Simple and Advanced databinding and their related help articles.

I hope this information helps.

Regards,
Tsvetoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Lee Malo
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Lee Springthorpe
Top achievements
Rank 1
Tsvetoslav
Telerik team
Share this question
or