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

Kendo Menu and Hyperlinks

1 Answer 739 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 30 Oct 2014, 05:55 PM
OK it seems to me that this should be a simple thing but for some reason it is not documented anywhere (at least I can't find it).
Using:
http://docs.telerik.com/kendo-ui/getting-started/using-kendo-with/aspnet-mvc/helpers/menu/overview#bind-kendo-menu-to-a-hierarchical-model

I have a working menu EXCEPT hyper links

Sure I can get it to fire the select event. What exact is being passed in. I can't get the values I set on the "item" object (Text or Url).

What are the available properties for the "item" object in the above example?

All I need to do is make the select function redirect to a new page. I would think that this is what 99% of your users would want to do. Why is an end-to-end example of a hierarchical model with hyperlinks not given?

Please provide this.

@(Html.Kendo().Menu()
.Name("adminMenu") //The name of the menu is mandatory. It specifies the "id" attribute of the widget.
.BindTo(Model, mappings =>
{
mappings.For<McGladrey.DOTT.DataModel.DOTTCustom.sp_GetUserTreeData_Result>(binding => binding //define first level of menu
.ItemDataBound((item, parent) => //define mapping between menu item properties and the model properties
{
item.Text = parent.NodeName;
})
.Children(parent => parent.ChildrenNodes)
); //define which property of the model contains the children
mappings.For<McGladrey.DOTT.DataModel.DOTTCustom.sp_GetUserTreeData_Result>(binding => binding
.ItemDataBound((item, child) =>
{
item.Text = child.NodeName;
item.Url = child.NodeAction;

}));
})
.Events(e=>e.Select("MenuSelected"))
.Orientation(MenuOrientation.Vertical)
)

<script type="text/javascript">

function MenuSelected(e)
{
alert(e.item.Text + " " + e.item.Url);

}
</script>

-Martin

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 03 Nov 2014, 04:28 PM
Hello Martin,

I assume you are struggling because the intellisense is not working, since there are two similar overload which for some reason cannot be resolved to give suggestions at the moment of typing. You can however specify the type of the parameters for the lambda function and you will start getting intelli-sense suggestions.

e.g.

@model IEnumerable<Kendo.Mvc.Examples.Models.Category>
 
@(Html.Kendo().Menu()
      .Name("Menu")
      .BindTo(Model, mappings =>
      {
            mappings.For<Kendo.Mvc.Examples.Models.Category>(binding => binding
                    .ItemDataBound((MenuItem item, Kendo.Mvc.Examples.Models.Category category) =>
                    {
                        item.Text = category.CategoryName;
                        item.Url = ...
                    })
                    .Children(category => category.Products));
            mappings.For<Kendo.Mvc.Examples.Models.Product>(binding => binding
                    .ItemDataBound((item, product) =>
                    {
                        item.Text = product.ProductName;
                    }));
      })
)

I guess the option you look for is the item.Url.

I hope this helps.

Regards,
Petur Subev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Menu
Asked by
Martin
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or