We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

contex menu with angular 1

I want to add a context menu with  options to predefined and you reach a function whit Angular Js 1









Attachment: Archivos_9ca9624b.7z

5 Replies

SR Suriyaprasanth Ravikumar Syncfusion Team October 26, 2016 08:53 AM UTC

Hi Daniel, 
Thanks for contacting Syncfusion support. 
Please find the response below: 
Query1: I want to add a context menu with  options to predefined and you reach a function whit Angular Js 1 
Solution: 
 Using contextMenuOpen client side event we can add custom menu items in TreeGrid. 
Please find the code snippet below. 
<div id="angulartreegrid" ej-treegrid 
                     e-datasource="data" 
                     e-contextmenuopen="contextmenuopen"> 
                </div> 
 
//Add custom menu item and handler fucntion 
function contextMenuOpen(args) { 
            var data; 
            data = args.item; 
            var contextMenuItems = [ 
             { 
                 headerText: "Custom", 
                 menuId: "Custom", 
                 eventHandler: customContextMenu, 
             } 
            ]; 
            args.contextMenuItems.push.apply(args.contextMenuItems, contextMenuItems); 
} 
function customContextMenu(args) { 
            alert("Custom context menu clicked"); 
} 
 
We have also prepared the sample for your reference. Please find the sample from below link 
Please find our online custom context menu sample link below 
For more information’s relates to custom context menu in TreeGrid please refer the following link. 
 
Please let us know if you require further assistance on this. 
 
Thanks&Regards, 
Suriyaprasanth R 



DA Daniel October 26, 2016 11:53 AM UTC

I want to point to a function within the angular controller within the angular scope, is this possible?


JS Jonesherine Stephen Syncfusion Team October 27, 2016 11:05 AM UTC

Hi Daniel, 
We can map the inline functions for context menu “eventHandler” to point the function within angular scope. 
Please find the code example below 
.controller('TreeGridCtrl', function ($scope) { 
                // 
            $scope.contextmenuopen = function contextMenuOpen(args) { 
            var data; 
            data = args.item; 
            var contextMenuItems = [ 
             { 
                 headerText: "Custom", 
                 menuId: "Custom", 
                 eventHandler:  function customContextMenu(args) { 
                                                  alert($scope.selectedRow); 
                                                  }, 
             } 
            ]; 
            args.contextMenuItems.push.apply(args.contextMenuItems, contextMenuItems); 
        };         
}); 
We have also modified the sample for your reference. Please find the sample from below link 
Please let us know if you require further assistance on this. 
Regards, 
Jone sherine P S 



DA Daniel November 5, 2016 12:50 AM UTC


what realmento wish it is that the context menu point to an angular function that is defined outside

Attachment: syn_f02b0558.rar


JS Jonesherine Stephen Syncfusion Team November 7, 2016 05:12 PM UTC

Hi Daniel, 
We can declare the “eventHandler” functions either inside/outside the angular scope and also we can define even handler as inline function or separate function. 
We can’t pass the custom arguments for event handler function, arguments will be passed from control while event is triggered. 
Please find the code example below. 
var contextMenuItems = [ 
               { 
                   headerText: "Custom", 
                   menuId: "Custom", 
                   eventHandler: $scope.ClickSubMenu, 
               } 
//handler function 
$scope.ClickSubMenu = function (args) 
           { 
               alert($scope.selectedRow); 
             } 
We have prepared the workaround and declared the “eventHandler” on outside of the “contextMenuOpen” action. 
Please find the sample from below location: 
 
Regards, 
Jone sherine P S  


Loader.
Up arrow icon