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

Remove Bound Fields From "Column" menu item of RadGrid HeaderContextMenu

1 Answer 90 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kaushal
Top achievements
Rank 1
Kaushal asked on 12 Apr 2011, 02:04 PM
Hi ALL,

         I have to implement headercontextmenu to radgrid header, for that i had set property of RadGrid HeaderContextMenu as true.

        
Now, i want to make some customized modification on same.

         I want to show/hide GroupBy and Ungroup menu item as per user selection, that i did, but problem is when GroupBy  and UnGroup menu item get hide seperator still there, now i want to hide that separator also.

         Second for "Column" menu item i got all my database fields in submenu list, like Id,FirstName,LastName,DOB now what i want i want to display only such type of fields not all, like i dont want to display ID field in submenu of Column menu item.

         Please help me on same.

1 Answer, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 15 Apr 2011, 04:40 PM
Hello Kaushal,

Please try using the following code in order to remove the "Columns" item and the corresponding separator:
protected void Page_Load(object o, EventArgs e)
{
    RadGrid1.HeaderContextMenu.ItemCreated += new RadMenuEventHandler(HeaderContextMenu_ItemCreated);
}
 
void HeaderContextMenu_ItemCreated(object sender, RadMenuEventArgs e)
{
    if (e.Item.Text == "Columns")
    {
        e.Item.Style.Add("display", "none");
        (sender as RadContextMenu).Items[e.Item.Index - 1].Remove();
    }
}

I hope it helps.

Best wishes,
Mira
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Kaushal
Top achievements
Rank 1
Answers by
Mira
Telerik team
Share this question
or