Telerik Forums
Kendo UI for jQuery Forum
21 answers
2.2K+ views
Hey, I read in the docs about the event 'select' when using the menu.  Does the fire whenever a menu item is clicked? If so, how do you handle that event?  
Steven Faulkner
Top achievements
Rank 1
 answered on 08 Sep 2020
6 answers
149 views
In the Kendo Tree View component, when you append a new item, the function will return a reference to the new node.  That way, it's easy to build a node hierarchy:
rootNode = myTreeView.append({ text: "MyRoot" }, null);
subNode = myTreeView.append({ text: "MySubNode" }, rootNode);
myTreeView.append({ text: "MyThirdLevelNode1" }, subNode);
myTreeView.append({ text: "MyThirdLevelNode2" }, subNode);

However, I can't find a way to do the same with the Kendo Menu component.  So far, the only I've found to create a menu dynamically is adding a specific ID and getting the menu item with this ID.
MyMenu.append('<li id="RootMenuItem" class="k-item">MyRootItem</li>');
MyMenu.append('<li id="MySubItem" class="k-item">SubItem</li>', $("#RootMenuItem"));

Is there a way to get the newly created item and reuse it as the parent reference for the menu?

Regards,

Simon








Neli
Telerik team
 answered on 02 Sep 2020
6 answers
423 views
The site has a sample code.
http://demos.kendoui.com/web/menu/api.html

With this all clear... Is there a possibility of adding attributes href, class, role? 
Neli
Telerik team
 answered on 02 Sep 2020
2 answers
58 views
I want to add language support to my Kendo UI Menu widget. There is no culture specific to it, how can I do it?
Furkan
Top achievements
Rank 2
 answered on 12 Aug 2020
1 answer
115 views

I'm looking at https://demos.telerik.com/kendo-ui/menu/context-menu and have a question about this piece of code:

var menu = $("#menu"),
    original = menu.clone(true);
 
original.find(".k-state-active").removeClass("k-state-active");
 
$("#apply").click(function (e) {
    e.preventDefault();
    var clone = original.clone(true);
 
    menu.getKendoContextMenu().destroy();
    clone.appendTo("#example");
 
    initMenu();
});

 

It clones the menu, it removes the active selection marker from any selected elements and then attaches a click event to all elements with Id = "apply".

But there are no apply elements in the code sample? And running this from the dojo with that code commented out seems to yield the same result.

Is it an example of how to handle context menus on other elements I might choose to put on that page? (but also for left-click though..?)

Ivan Danchev
Telerik team
 answered on 04 Aug 2020
1 answer
183 views

Hi all,

I've been trying for hours to dynamically populate a kendo sub-menu with processed database items, and have those menu items call a javascript function on click. I've read all over the internet that with jQuery, I should really be using event listeners, but that's really difficult when the kendo menu populates its menus with identical IDs and classes on all its items, and I'd have to dynamically create different numbers of event listeners based on the quantity of items in the menu, and I don't even know if that's possible. Therefore, I'm trying to populate the menu with custom div elements with ng-click data to call a function. My javascript file is separate from the HTML file, but I know they're connected properly because other places on the page interact with the javascript functions just fine. When I use ng-click in the inner div I'm inserting via json, absolutely nothing happens. The breakpoint in the called function is never hit, but I know the function works because I created a simple test element elsewhere on the page using the exact same ng-click logic, and it called and executed the function just fine. We're using transformative kendo rather than the raw HTML tags. Here's a code snippet:

//Transform the kendo menu
$("#kendoMenu").kendoMenu();
//other code populating $scope.listOfMilestone from the database, we know that works because the vis timeline generates correctly
var milestonesReadable = new Array();
for (var i = 0; i < $scope.listOfMilestones.length; i++) {
    var milestoneDate = new Date($scope.listOfMilestones[i].StartDate);
    var dateString = (milestoneDate.getMonth() + 1) + "/" + milestoneDate.getDate() + "/" + milestoneDate.getFullYear();
    milestonesReadable.push({
        text: "<div ng-click=\"navigate('" + dateString + "')\">" + $scope.listOfMilestones[i].Title + " (" + dateString + ")</div>",
        encoded: false
    });
}
$("#dropdownMilestoneList").kendoMenu({
                    dataSource: milestonesReadable
});

//way further down in the javascript:
$scope.navigate = function (dateString) {
    debugger;
    $scope.timeline.moveTo(dateString);
}

Here's the essential structure of our <ul> structure that the kendo menu uses:

<ul id="kendoMenu>
    <li>
        Customize Timeline
        <ul>
            <!--many layers of menu that we know all work correctly-->
            <li>
                Functions
                <ul>
                    <li>
                        Go to Milestone
                        <ul id="dropdownMilestoneList></ul>
                    </li>
                </ul>
            </li>
        </ul>
    </li>
</ul>

When that innermost ul tag is populated (which appears correctly with appropriate data), and is checked using inspect element, you can see inside each <span class="k-link"> tag that indicates a menu item, there is indeed a div element with correct ng-click data, exactly as it was in my test element that worked. However, when you click on any of these menu items, the ng-click just doesn't do anything. No function call, no error, just nothing. When I replace it with the base HTML's onclick, an error is thrown, though:

Uncaught ReferenceError: navigate is not defined
    at HTMLDivElement.onclick

I'm at a total loss. Any advice would be appreciated.

Thanks.

Martin
Telerik team
 answered on 07 Jul 2020
1 answer
163 views

Hi

Just upgraded to 2019.3.917 and we have lost our ability to enable/disable menu items

here is an example of how we populate a menu datasource in javascript:

<script>
   var sa=[], var mm=[];

  sa.push({ text: '<span id=openPlan><span style="display: inline-block; width: 190px;" >Open Plan...</span><span>Ctrl+O</span></span>',  encoded: false });

  sa.push({ text: '<span id=readPlan><span style="display: inline-block; width: 190px;" >Read Plan...</span><span>Ctrl+R</span></span>',  encoded: false });
  sa.push({ text: '<span id=closePlan><span style="display: inline-block; width: 190px;" >Close Plan...</span><span>Ctrl+S</span></span>', encoded: false });

  mm.push({ text: "Main Menu", items: sa });
      $("#mainMenu").kendoMenu({
        dataSource: mm
    });

    // get a reference to the menu widget
    var menu = $("#mainMenu").data("kendoMenu");
    // disable menu item with id 
    menu.enable("#closePlan", false);
</script>

 

I have an example here: https://dojo.telerik.com/EMeLAdAd

If you set then library to '2019.1.115' it works and the 'Close Plan' item gets disabled, but if you set it to '2019.3.917' then it stays enabled!

 

If anyone could let me know what I am doing wrong here I would be grateful.

 

Thanks

James

Petar
Telerik team
 answered on 17 Oct 2019
1 answer
88 views

Hi,

I'm wondering if there is a way to expand sub-menu items between the root items when the menu has a vertical orientation

For example for the menu below the space between products and blog would expand to accommodate the sub-menu. Would another control be better for this? 

<!DOCTYPE html>
<html>
<head>
    <style>html { font-size: 14px; font-family: Arial, Helvetica, sans-serif; }</style>
    <title></title>
 
     
 
</head>
<body>
            <ul id="menu">
                <li>
                    Products
                    <ul>
                        <li>
                            Furniture
                            <ul>
                                <li>Tables & Chairs</li>
                                <li>Sofas</li>
                                <li>Occasional Furniture</li>
                                <li>Children's Furniture</li>
                                <li>Beds</li>
                            </ul>
 
 
                        </li>
                        <li>
                            Decor
                            <ul>
                                <li>Bed Linen</li>
                                <li>Throws</li>
                                <li>Curtains & Blinds</li>
                                <li>Rugs</li>
                                <li>Carpets</li>
                            </ul>
                        </li>
                        <li>
                            Storage
                            <ul>
                                <li>Wall Shelving</li>
                                <li>Kids Storage</li>
                                <li>Baskets</li>
                                <li>Multimedia Storage</li>
                                <li>Floor Shelving</li>
                                <li>Toilet Roll Holders</li>
                                <li>Storage Jars</li>
                                <li>Drawers</li>
                                <li>Boxes</li>
                            </ul>
 
                        </li>
                        <li>
                            Lights
                            <ul>
                                <li>Ceiling</li>
                                <li>Table</li>
                                <li>Floor</li>
                                <li>Shades</li>
                                <li>Wall Lights</li>
                                <li>Spotlights</li>
                                <li>Push Light</li>
                                <li>String Lights</li>
                            </ul>
                        </li>
                    </ul>
                </li>
                 
                <li>
                    Blog
                </li>
                <li>
                    Company
                </li>
                <li>
                    Events
                </li>
                <li disabled="disabled">
                    News
                </li>
            </ul>
        <style>
        </style>
        <script>
            $(document).ready(function() {
                $("#menu").kendoMenu({
                            orientation: "vertical"
                        });
            });
           
        </script>
  <style>
    .k-menu-vertical /* for all horizontal menus */
{
   display: inline-block;
}
    .k-menu .k-i-arrow-60-right {
   display: none;
}
    </style>
 
 
</body>
</html>
Ivan Danchev
Telerik team
 answered on 05 Sep 2019
1 answer
102 views

Hello,

I use menu in toolbar as buttons with class k-icon

When i'm focus cursor on menu then icon changed to icon k-loading

Example: https://dojo.telerik.com/UXoGefaj/2

Error ocсure after update to kendo ui version 2019.2.619.

Dimitar
Telerik team
 answered on 17 Jul 2019
1 answer
776 views

On grid right click context menu's open event, how does one get the grid row's data item:

function grid_menu_open(e) {

}

Edward
Top achievements
Rank 1
 answered on 19 Jun 2019
Narrow your results
Selected tags
Tags
+? more
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?