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

adding menu using web-service / best practices

1 Answer 254 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Piyush Bhatt
Top achievements
Rank 2
Piyush Bhatt asked on 21 Dec 2011, 06:45 PM

I wanted to find out what is the best practice for showing menu in the application if we are using KendoUI. Whether it should be rendered from the server side using <ul> <li> tags or whether we should add dynamically using a web-service.

I prepared a blog post with an example of how I did this but I am not too sure if this would be the recommended way going forward. -  http://piyushbhatt.blogspot.com/2011/12/kendoui-adding-menu-using-web-service.html 

Overall - I think we would need the functions in kendoUI objects' such a way that developer should not have to use selectors (like "li:last" or "li:first") etc and can work with the objects and methods only. 

Again this is not direct question per say - but to know your thoughts on best practices and how you think people will be using various widgets in large applications.

1 Answer, 1 is accepted

Sort by
0
Kamen Bundev
Telerik team
answered on 22 Dec 2011, 11:27 AM
Hello Piyush,

You can add one or several items directly (along with sub items, images, sprites, etc) by passing a JSON object as a Menu dataSource, like this:
$("#menu").kendoMenu({
    dataSource: [{
        text: "Item 1",
        url: "http://www.kendoui.com"                // Link URL if navigation is needed, optional.
    },
    {
        text: "Item 2",
        imageUrl: "http://www.kendoui.com/test.jpg", // Item image URL, optional.
        items: [{                                    // Sub item collection
             text: "Sub Item 1"
        },
        {
             text: "Sub Item 2"
        }]
    },
    {
        text: "Item 3",
        spriteCssClass: "imageClass3"                // Item image sprite CSS class, optional.
    }]
});


The same JSON object can be used in append() too. Our documentation will get these updates soon.

All the best,
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!
Tags
Menu
Asked by
Piyush Bhatt
Top achievements
Rank 2
Answers by
Kamen Bundev
Telerik team
Share this question
or