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

How to Bind the Object List to Menu Controller

1 Answer 152 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Erandika
Top achievements
Rank 1
Erandika asked on 05 Feb 2014, 02:06 AM
Hi,

I want to bind the object list (object contain the two properties called Name and ID) and when i select Menu Item I want to get post request which is contain the selected object Name and ID. Is there anyway to do this with MVC menu control?

Thanks,
Erandika.

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 07 Feb 2014, 06:39 AM
Hello Erandika,

When you bind your Menu to a .net collection. You can construct the URL and add parameters to it based on the collection that you bind to.

Here is a small example I made by modifying one of our examples.


@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((item, category) =>
                    {
                        item.Text = category.CategoryName;
                    })
                    .Children(category => category.Products));
            mappings.For<Kendo.Mvc.Examples.Models.Product>(binding => binding
                    .ItemDataBound((item, product) =>
                    {
                        item.Text = product.ProductName;
                        item.Url = "http://" + product.CompanySite+ "?someParam=foo";
                    }));
      })
)


Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Menu
Asked by
Erandika
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or