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

Different Header Context Menu for each Radgrid column

3 Answers 154 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sathya
Top achievements
Rank 1
Sathya asked on 24 Jul 2012, 12:24 PM
Hi

    I am working on Radgrid, i tried to create different header context menu for each column in "OnPreRenderComplete", but the grid repeat the same menu for each column. The code i tried is here. 

  protected override void OnPreRenderComplete(EventArgs e)
    {
        RadContextMenu menu = AnswerGenMainGrid1.HeaderContextMenu;
        
        foreach (GridColumn gridColumn in AnswerGenMainGrid1.MasterTableView.RenderColumns)
        {
            RadMenuItem columnItem = new RadMenuItem();
            columnItem.Attributes["ColumnName"] = "";
            columnItem.Attributes["TableID"] = "";
            columnItem.Value = "∑";
            columnItem.Text = "∑";
            columnItem.PostBack = true;
            menu.Items.Add(columnItem);
            RadMenuItem columnItem1 = new RadMenuItem();
            columnItem1.Attributes["ColumnName"] = "";
            columnItem1.Attributes["TableID"] = "";
            columnItem1.Value = "%";
            columnItem1.Text = "%";
            columnItem1.PostBack = true;
            menu.Items.Add(columnItem);
            menu.Items.Add(columnItem1);
        }


        base.OnPreRenderComplete(e);
        
    }

I know here i am creating one menu and adding it to all columns. But i couldn't find anyother sample code for creating different menu item for different columns in grid.

Is there anyother solution to implement this?

3 Answers, 1 is accepted

Sort by
0
Milena
Telerik team
answered on 27 Jul 2012, 11:13 AM
Hello Sathya,

You can achieve your goal as use OnHeaderMenuShowing client event, there you can access RadMenu collection of items and depending on the column to add/remove items. More information about the methods, which could be used, find here.

Greetings,
Milena
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
G
Top achievements
Rank 1
answered on 11 Dec 2017, 05:21 AM
In the radgrid header context menu, while deselecting all the columns from the menu but we can not deselect the last column as it is read only. Is it possible to deselect the last column also?
0
Eyup
Telerik team
answered on 13 Dec 2017, 07:12 AM
Hello,

This is the default behavior. The last column, which remains visible regardless of its order position, will have its checkbox disabled in order to prevent hiding it. Otherwise, the grid will lose its structure and the user won't be able to see any data.

Regards,
Eyup
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Sathya
Top achievements
Rank 1
Answers by
Milena
Telerik team
G
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or