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

Help! How to set an ID for TreeView item (node)?

0 Answers 115 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Tomas
Top achievements
Rank 1
Tomas asked on 03 Oct 2012, 12:23 PM
Hello, i have a TreeView in my MVC application. When certain item is pressed, the div on page should change responding to the item ID.  There is my code for that page (view):

@model List<Omnitel.Models.Directory>

    @(Html.Kendo().TreeView()
            .Name("Treeview")
            .Events(events => events
                .Select("onSelect")
            )
            .BindTo(Model, mapping =>
            {
                mapping.For<Omnitel.Models.Directory>(binding => binding
                        .ItemDataBound((item, category) =>
                        {
                            item.Id = category.Id;
                            item.Text = category.Title;
                            item.BindTo(category.SubDirectories, mapping2 =>
                            {
                                mapping2.For<Omnitel.Models.Directory>(binding2 => binding2
                                        .ItemDataBound((item2, category2) =>
                                        {
                                            item2.Id = category2.Id;
                                            item2.Text = category2.Title;
                                            item2.BindTo(category2.SubDirectories, mapping3 =>
                                            {
                                                mapping3.For<Omnitel.Models.Directory>(binding3 => binding3
                                                        .ItemDataBound((item3, category3) =>
                                                        {
                                                            item3.Id = category3.Id;
                                                            item3.Text = category3.Title;
                                                        }
                                                ));
                                            });
                                        }
                                ));
                            });                      
                        }
                ));
            })
    )

    <script>
        var treeview;
        function onSelect(e) {
            var url = @Url.Action("GetDocument", "TreeView", new { e.sourceNode.ID );
        }
    </script>

As u can see, i want to put put an Id in each item. Is it possible? and how? Need fast response...

No answers yet. Maybe you can help?

Tags
TreeView
Asked by
Tomas
Top achievements
Rank 1
Share this question
or