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

[Solved] Binding to Model

1 Answer 139 Views
Menu
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Scott Rose
Top achievements
Rank 1
Scott Rose asked on 01 Apr 2010, 12:42 AM
I am having trouble getting the Binding to Model to work.  If I only have the test property populated on the menu item everything works great.  As soon as I try adding a Url or action and controller I run into problems.  In the simplest test I tried just adding a url to the child items, but in doing so only the first level of the menu shows up.  The children are no longer rendered.

My code example below is pulled from the telerik examples with just the Url being populated as the only thing that was changed.  Before adding this everything renders fine, but with no way to have the link direct to the page I need is a little useless.  Can you point out what I'm doing wrong?

<%= Html.Telerik().Menu()
        .Name("Menu")
        .BindTo(Model, mappings =>
        {
            mappings.For<TestSite.OM.Category>(binding => binding
                    .ItemDataBound((item, category) =>
                    {
                        item.Text = category.CategoryName;
                    })
                    .Children(category => category.Products));
            mappings.For<TestSite.OM.Product>(binding => binding
                    .ItemDataBound((item, product) =>
                    {
                        item.Text = product.ProductName;
                                                item.Url = "http://localhost/ViewItem/" + product.ProductName;
                    }));
        })
%>

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 01 Apr 2010, 09:15 AM
Hello Scott Rose,

The code snippet which you provide looks correct. The problem could be somewhere else in the implementation. I have attached a simple test project which implements the required functionality.

Sincerely yours,
Georgi Krustev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Menu
Asked by
Scott Rose
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or