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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

contex menu with angular 1

Thread ID:

Created:

Updated:

Platform:

Replies:

127092 Oct 25,2016 03:18 PM UTC Nov 7,2016 05:12 PM UTC JavaScript 5
loading
Tags: ejTreeGrid
Daniel
Asked On October 25, 2016 03:18 PM UTC

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









Attachment: Archivos_9ca9624b.7z

Suriyaprasanth Ravikumar [Syncfusion]
Replied On 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 


Daniel
Replied On 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?

Jonesherine Stephen [Syncfusion]
Replied On 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 


Daniel
Replied On 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

Jonesherine Stephen [Syncfusion]
Replied On 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  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;