New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Prevent columns from being hidden via the HeaderContextMenu


How do I prevent certain columns from appearing in the HeaderContextMenu? I don't want users to hide some columns.


The RadContextMenu is implemented using a RadMenu - which provides access to the full RadMenu API. When the RadContextMenu is opened, a client-side event can be triggered. That event can be used to hide specific elements in the RadMenu - making it impossible for them to be selected.

In the RadGrid markup, create an event handler for the RadContextMenu using the OnClientItemOpening event.

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" OnNeedDataSource="RadGrid1_NeedDataSource"
    FilterType="HeaderContext" EnableHeaderContextFilterMenu="true" EnableHeaderContextMenu="true">
            <telerik:GridBoundColumn DataField="Id" />
            <telerik:GridBoundColumn DataField="Name" />
    <HeaderContextMenu OnClientItemOpening="hideColumnOption" />

Use JavaScript to add the Display: None style to any items you want to be hidden. Items are selected by Index.

function hideColumnOption(sender, args) {
    var item = args.get_item();

    //Hide the column at index 1
    item.get_items().getItem(1).get_element().style.display = "none";
In this article