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

EnableHeaderContextMenu column hiding problem

1 Answer 59 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dheeraj
Top achievements
Rank 1
Dheeraj asked on 07 Jun 2010, 03:06 PM
Hi,
       I have a column in grid which I am hiding (Display="false") from users,and on click of a button I am accesing values from that column.I am using  HeaderContextMenu, form which user will be able to select and unselect the column(for personalization perpose i am giving this option to user).
                              The problem is that the hidden columns are also visible in  HeaderContextMenu.I want that those hidden columns should not come in  HeaderContextMenu. Please suggest me How to remove HeaderContextMenu - column values.

Regards,
Dheeraj         

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 10 Jun 2010, 01:16 PM
Hi Dheeraj,

In order to achieve your goal, you can handle the grid header context menu ItemCreated event. There hide the item which corresponds to the column you want to be always visible. Your code should resemble the below:

protected void Page_Load(object sender, EventArgs e)
{
    RadGrid1.HeaderContextMenu.ItemCreated += new RadMenuEventHandler(HeaderContextMenu_ItemCreated);
}
void HeaderContextMenu_ItemCreated(object sender, RadMenuEventArgs e)
{
    if (e.Item.Value.Contains("OrderID"))
    {
        e.Item.Visible = false; //hide the OrderID column
    }
}

Give it a try and let me know if it works for you.

Sincerely yours,
Iana
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
Dheeraj
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or