This is a migrated thread and some comments may be shown as answers.

Dynamically adding items

6 Answers 340 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Arni
Top achievements
Rank 1
Arni asked on 04 Dec 2011, 05:27 PM
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? 

6 Answers, 1 is accepted

Sort by
0
Kamen Bundev
Telerik team
answered on 05 Dec 2011, 04:49 PM
Hi Taras,

Currently, you can set the following attributes dynamically:
{
    text: "Link text",
    url: "http://www.gooogle.com",
    enabled: true,
    imageUrl: "images/something.png",
    spriteCssClass: "spriteClass"
}

where imageUrl and spriteCssClass will trigger the rendering of an IMG or SPAN elements inside. You can also specify an items: [ ] property with an array of subitems which will be also rendered. We will gradually add more properties with new releases.

Other than that, you can init several new menu items with a plain string, like this:
menu.append( "<li class='k-item'><a href='http://www.google.com' class='link1'>Link 1</a></li><li class='k-item'><a href='http://www.google.com' class='link2'>Link 2</a></li>" );
In it you can place any attributes you want, as long as class='k-item' remains.

Kind regards,
Kamen Bundev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Arni
Top achievements
Rank 1
answered on 05 Dec 2011, 06:45 PM
Thanks for the answer Kamen Bundev.

I think it needs to be improved  API

/*
    * Get Item
    */    
    function getItem(target,menu) {
        var itemIndexes = target.split(/[.,]/),
            rootItem = itemIndexes[0] != "" ?
            menu.element.children("li").eq(itemIndexes[0]) : false;
  
            return itemIndexes.length > 1 ?
            rootItem.find(".k-group > .k-item").eq(itemIndexes[1]) :
            rootItem;
    }
It's not usability.
0
Kamen Bundev
Telerik team
answered on 06 Dec 2011, 09:38 AM
Hello Arni,

The function below is used to separate the user input and find a specific menu item by root.sub indexes. It is not part of the API itself. Instead you can find your items using jQuery and directly pass them to the API methods as a jQuery object or HTML element. If you had something else in mind, can you explain it in more detail?

Greetings,
Kamen Bundev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Arni
Top achievements
Rank 1
answered on 07 Dec 2011, 04:57 PM
Right. It is not part of the API itself. But I think that it would be useful as part of the API.
1
Ody
Top achievements
Rank 1
Veteran
answered on 28 Aug 2020, 08:00 PM

Yes!  The Menu API functionality for finding, adding and removing items is so skeletal.  It's especially arcane when it comes to adding items to sub-menus.  Same for the documentation for the control.  I have never experienced, in my like 10+ years of using Telerik products, a control so lacking in what would be considered basic functionality.

 

I'm trying to add a responsive context menu on the right for when the user re-sizes the screen, like your Toolbar control.   The menu.append functionality is so retarded - it adds completely blank < li > items in between each thing I append, even though I'm literally setting the text of the append object to a single < li > item.  Seriously you folks need to bring this control's API up to basic level standards for your other controls.    I've been stepping thru code line by line to figure out what it things is a wrapper versus an element versus a menu item versus a sub item, it's melting my brain.

 

 

0
Neli
Telerik team
answered on 02 Sep 2020, 01:46 PM

Hello Ody,

Thank you very much for the feedback. We always appreciate any feedback for the Kendo widgets, as well as for our documentation. We are trying to improve our products, demos, and documentation constantly. I would encourage you to log your ideas for features or improvements in our official Feedback Portal. Thus, we could track the community interest on each issue and decide where to put more effort. 

I have tested the append functionality in a sample Dojo example, where on a button click a new item is appended to a ContextMenu. The new item is appended wrapped in a <li> element. However, no empty <li> is appended on my end (screencast). Could you please take a look at the Dojo example and let me know if I am missing something?

Looking forward to your reply. 

Regards,
Neli
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

Tags
Menu
Asked by
Arni
Top achievements
Rank 1
Answers by
Kamen Bundev
Telerik team
Arni
Top achievements
Rank 1
Ody
Top achievements
Rank 1
Veteran
Neli
Telerik team
Share this question
or