Dynamic Context menus

8 posts, 1 answers
  1. Rishi
    Rishi avatar
    42 posts
    Member since:
    Feb 2010

    Posted 09 Mar 2010 Link to this post

    Hi

    Is there a way to create and attach context menus to the items on the tree based on the level they are on after the data is bound to the tree??
    Would it be any different if it were a load on demand tree.?
    Because I would have or not have different context menus on different nodes depending on their level.

    Thanks
  2. Answer
    Schlurk
    Schlurk avatar
    812 posts
    Member since:
    May 2009

    Posted 09 Mar 2010 Link to this post

    You should be able to see an example of how to do this in this demo :)
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Thomas
    Thomas avatar
    13 posts
    Member since:
    Feb 2008

    Posted 18 Apr 2011 Link to this post

    The posted solution works fine in cases where you can load the permissions or lets say the "context menu items that should be shown on a specific item" are know at the time when you create the treeviewitem. Is there any solution to load this information on demand. So, for example:
    A tree with some item A, B  and C.
    A context menu with the items "Add" and "Delete"
    When the user requests the context menu for item A we have to ask the server if the user is allowed to add/delete.

    I can't do a postback, otherwise the context menu disappears again. I can't use any async webservice-call either.
    Any suggestions how I could solve this?

    Thanks in advance,
    Thomas
  5. Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 21 Apr 2011 Link to this post

    Hi Thomas,

    If the context that you need to request is the user permissions, then you can create the context menu server side with regard to this factor. Could you, please, share what seems to be the problem implementing it this way?


    Regards,
    Nikolay Tsenkov
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  6. Thomas
    Thomas avatar
    13 posts
    Member since:
    Feb 2008

    Posted 26 Apr 2011 Link to this post

    The problem is that:
    1. The user permissions are item-specific. A user might have the right to rename and delete "tree item A", but does not have the permission to delete "tree item B"
    2. The tree is large and loading the permission for one tree item does take very long. So loading the permissions for all items when the tree is created is infeasible.

    Therefore we want to load the permissions for a tree item from the server when the user right-clicks a tree item and before the menu is shown.
    OnClientContextMenuShowing seemed perfect, but doesn't really work out, as mentioned before. A server-side event OnContextMenuShowing would solve the problem, but doesn't exist.
    Any workarounds?

    Regards,
    Thomas

  7. Helen
    Admin
    Helen avatar
    1052 posts

    Posted 29 Apr 2011 Link to this post

    Hello Thomas,

    Please find attached a sample how to achieve this with RadAjaxManager.

    Hope it helps.

    Greetings,
    Helen
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  8. Thomas
    Thomas avatar
    13 posts
    Member since:
    Feb 2008

    Posted 02 May 2011 Link to this post

    Hello,

    Thank you very much for your effort. But unfortunately, this solution has a problem:

    You show the menu with the client script:
    var menu = $find("<%= Menu1.ClientID %>");
    menu.showAt(menuX, menuY);

    The menu shows up, but none of the click-events of the context menu items (OnClientContextMenuItemClicking, OnClientContextMenuItemClicked, OnContextMenuItemClick,...) works anymore. 

    To verify this... in your example solution add the to client events to the RadTreeView-Tag:
    OnClientContextMenuItemClicking="MenuItemClicking" OnClientContextMenuItemClicked="MenuItemClicked"
    and some event handlers like this:
    function MenuItemClicking(sender, args) {
        alert("menu item clicking");
    }
    function MenuItemClicked(sender, args) {
        alert("menu item clicked");
     }

    Nothing happens when you click on a menu item (no matter if it's enabled or not)

    Is there any way to fix this?
  9. Helen
    Admin
    Helen avatar
    1052 posts

    Posted 03 May 2011 Link to this post

    Hi Thomas,

    Please modify the "OnAjaxResponseEnd"  javascript function like the following:

    function OnAjaxResponseEnd(sender, args) 
    {
        if (args.EventArgument == nodeText) {
        var menu = $find("<%= Menu1.ClientID %>");
        var tree = $find("<%= RadTreeView1.ClientID %>");
         
        menu.showAt(menuX, menuY);
        menu.add_itemClicking(MenuItemClicking);
        menu.add_itemClicking(MenuItemClicked);
        }                     
    }

    Hope it helps.

    Kind regards,
    Helen
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017