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

Prevent ExpandMode=WebService nodes from being cached

9 Answers 190 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Aaron
Top achievements
Rank 1
Aaron asked on 23 Sep 2008, 02:57 AM
Hello,

I've got a rad menu that has a subnode that is being populated from a webservice call. I need to have the node data be refreshed each time the menu is expanded, but it appears that the call is cached once the data is first loaded. I tried setting the persistloadondemanditems attribute to "false" but this doesn't seem to change the behavior. Is there any way to accomplish this?

Thanks,
Aaron

9 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 23 Sep 2008, 10:42 AM
Hello Aaron,

You should use the OnClientItemClosed event like this:

        <script type="text/javascript">
        function itemClosed(sender, args)
        {
            var item = args.get_item();
            item.set_expandMode(Telerik.Web.UI.MenuItemExpandMode.WebService);
            item.get_items().clear();
            item._itemsLoaded = false;
        }
        </script>
        <telerik:RadMenu ID="RadMenu1" runat="server" Skin="Default" OnClientItemClosed="itemClosed">

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Aaron
Top achievements
Rank 1
answered on 23 Sep 2008, 12:58 PM
Thank you so much. That works perfectly. You guys are great.
0
Andrey
Top achievements
Rank 1
answered on 29 Dec 2008, 08:18 AM

There is problem happens when you have server-side "onitemclick" for RadMenu. The problem happens when you click web-service-generated menu, exception raised (out of index). To prevent this exception, i put a little modified code not to OnClientItemClosed but to OnClientShown of RadMenu:

Thus, you have to clear cache not in "closed" event but before showing menu in OnClientShown event.

My code:

function onMnuOperationsShown(sender, args)  
        {  
 
            //var item = args.get_item();  
            lastClickedOperation = mnuOperations._children._array[0];  
            if(lastClickedOperation)  
            {  
                lastClickedOperation.set_expandMode(Telerik.Web.UI.MenuItemExpandMode.WebService);  
                lastClickedOperation.get_items().clear();  
                lastClickedOperation._itemsLoaded = false;  
            }       
        } 

0
James
Top achievements
Rank 1
answered on 24 Jun 2010, 09:23 PM
This works for me but when the child menu group opens the next time, the borders are removed.  I'm using rounded corners and the top, left, right, and bottom borders are all missing.  Is there something else that has to be done?

On the first load it always displays correctly, it is only on subsequent loads that this occurs.
0
Yana
Telerik team
answered on 30 Jun 2010, 11:08 AM
Hi James,

Which version of the controls exactly you're using?

Regards,
Yana
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
0
Veenu
Top achievements
Rank 1
answered on 16 Sep 2010, 03:48 PM
Hi ,

Above solution is working fine in IE but in Firefox Menu items are not shown for second time.
Code is executed i.e Binding code of RadMenu Items but MenuItems are not shown in UI.

Thanks
Veenu
0
Yana
Telerik team
answered on 22 Sep 2010, 10:00 AM
Hi Veenu,

This is too old thread (since 2008) and many things are changes since then. So please explain in more details your problem and send us sample code. Thanks

Sincerely yours,
Yana
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
0
Veenu
Top achievements
Rank 1
answered on 24 Sep 2010, 06:42 AM
Hi Yana,

New thread is created for the same . Please have a look.

http://www.telerik.com/community/forums/aspnet-ajax/menu/radmenuitem-issue-on-clear-items-in-js-prevent-expandmode-webservice-nodes-from-being-cached.aspx


Thanks
Veenu
0
Tom
Top achievements
Rank 1
answered on 22 Jan 2013, 04:09 PM
This looks like a bug on a menu that is recreated on the client each time it is shown.

When you select a child menu item it's 'index' gets cached into _selectedItemIndex (e.g. the 1st child of the 1st root item  as "-1,0" ). _selectedItemIndex remains on the next click, even after callng menu.get_items().clear() or item.set_selected(false) and menu.get_items().removeAt(i) on each item.  This value gets passed to _findItemByHierarchicalIndex(e) as e. If you follow the logic of the _findItemByHierarchicalIndex(),
 c = -1 where d = 0 and b = ["-1", "0"];
and
a = null after a = f._getChildren().getItem(-1);
and
f = a, so on the next iteration it's dotting into a null f on f._getChildren()

Why does this occur? How to correct it?
_findItemByHierarchicalIndex:function(e)
{
  var a=null;
  var f=this;
  var b=e.split(":");
  for(var d=0;d<b.length;d++)
  {
    var c=parseInt(b[d]);
    if(f._getChildren().get_count()<=c)
    {
      return null;
    }
    a=f._getChildren().getItem(c);
    f=a;
  }
  return a;
}
Tags
Menu
Asked by
Aaron
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Aaron
Top achievements
Rank 1
Andrey
Top achievements
Rank 1
James
Top achievements
Rank 1
Yana
Telerik team
Veenu
Top achievements
Rank 1
Tom
Top achievements
Rank 1
Share this question
or