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

[Solved] GridHeaderContextMenu items count null when page is idle for some time

5 Answers 87 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Neerajan
Top achievements
Rank 1
Neerajan asked on 05 Mar 2013, 08:58 AM
Hello,

I have added a grid header context menu on OnPreRenderEvent .
When I leave the page idle for some time and  try to do something with the grid later, the gridheadercontext menu items count is zero. and error is thrown.

Does anyone have any idea?

Thanks,
Neerajan

5 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 08 Mar 2013, 09:50 AM
Hi Neerajan,

Can you please verify that you are closely following the steps provided in the following topic when adding the menu items programmatically?
http://www.telerik.com/help/aspnet-ajax/grid-header-context-menu.html

Kind regards,
Eyup
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
Neerajan
Top achievements
Rank 1
answered on 08 Mar 2013, 10:20 AM
Yes, I have followed the same steps as mentioned in the link. I have added a custom header context menu item  and inserted it to some position in header contextmenu. For the first time it is OK, menu is inserted to the desired position.

But, when the page is idle for some time, and any task is performed in page like sorting,unsorting, ajax request is created and then the rad menu items count is zero. Since, the rad menu items count is zero, the menu cannot be inserted and throws index out of range exception.

    GridHeaderContextMenu menu = RadGrid1.HeaderContextMenu;

    var item = new RadMenuItem { Text = @"Custom menu to carry out custom task", Value = @"CustomMenu" };

    item.Attributes["ColumnName"] = string.Empty;

    item.Attributes["TableID"] = string.Empty;

    menu.Items.Insert(5, item);

This code has been used onprerender event.

0
Eyup
Telerik team
answered on 13 Mar 2013, 09:22 AM
Hi Neerajan,

I am afraid we are not able to replicate the issue locally. Try to implement this logic on PreRenderComplete event as suggested in the provided topic.

If the issue remains, please provide us the exact steps to reproduce the issue or open a support ticket to send us a sample runnable application demonstrating the erratic behavior. Thus, we will be able to further analyze the problem and provide a proper solution.

Greetings,
Eyup
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
Neerajan
Top achievements
Rank 1
answered on 13 Mar 2013, 10:27 AM
I had added the code in OnPreRenderComplete  event but I mentioned OnPreRender event, my bad.

The exact steps are mentioned in above chain. 

Thanks,
Neerajan

0
Eyup
Telerik team
answered on 15 Mar 2013, 12:34 PM
Hi Neerajan,

I have prepared a sample RadGrid web site where I implemented the described scenario. Can you please check out the attached application and verify that it works as expected on your end, too?

Regards,
Eyup
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
Grid
Asked by
Neerajan
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Neerajan
Top achievements
Rank 1
Share this question
or