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

Problem hidding the column in ContextMenu

1 Answer 35 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Sudha
Top achievements
Rank 1
Sudha asked on 08 Nov 2011, 11:51 AM
HI,
I have set EnableHeaderContextMenu= true in the rad grid. In this ContextMenu I am getting all the Column names which are in the grid.
My requirement is , I want only those coulmns for which i have set Visible = true. I do not want the columns for which i have set Display=False. I do not want to set Visible = False for those particular columns as i want those coulmns to be rendered.
Kindly help me resolving this issue as early as possible.

Thanks,
Sudha.

1 Answer, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 09 Nov 2011, 04:26 PM
Hello Sudha,

Please use the following code in order to hide the desired columns from the context menu:
protected void Page_Init(object sender, EventArgs e)
{
    RadGrid1.HeaderContextMenu.ItemCreated += new RadMenuEventHandler(HeaderContextMenu_ItemCreated);
}
 
void HeaderContextMenu_ItemCreated(object sender, RadMenuEventArgs e)
{
    if (e.Item.Value.Contains("ColumnUniqueName"))
    {
        e.Item.Visible = false; //hide the desired column
    }
}

I hope this helps.

Regards,
Mira
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
Tags
Menu
Asked by
Sudha
Top achievements
Rank 1
Answers by
Mira
Telerik team
Share this question
or