Prevent ExpandMode=WebService nodes from being cached

10 posts, 1 answers
  1. Aaron
    Aaron avatar
    2 posts
    Member since:
    Aug 2008

    Posted 22 Sep 2008 Link to this post

    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
  2. Answer
    Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 23 Sep 2008 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Aaron
    Aaron avatar
    2 posts
    Member since:
    Aug 2008

    Posted 23 Sep 2008 Link to this post

    Thank you so much. That works perfectly. You guys are great.
  5. Andrey
    Andrey avatar
    1 posts
    Member since:
    Dec 2008

    Posted 29 Dec 2008 Link to this post

    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;  
                }       
            } 

  6. James
    James avatar
    35 posts
    Member since:
    Apr 2010

    Posted 24 Jun 2010 Link to this post

    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.
  7. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 30 Jun 2010 Link to this post

    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
  8. Veenu
    Veenu avatar
    45 posts
    Member since:
    Jun 2008

    Posted 16 Sep 2010 Link to this post

    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
  9. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 22 Sep 2010 Link to this post

    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
  10. Veenu
    Veenu avatar
    45 posts
    Member since:
    Jun 2008

    Posted 24 Sep 2010 Link to this post

    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
  11. Tom
    Tom avatar
    4 posts
    Member since:
    Aug 2011

    Posted 22 Jan 2013 Link to this post

    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;
    }
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017