Im implementing some orgchart, im new to mvc and kendo.. how do i implement onclick event for thekendo tree view
Html.Kendo().TreeView()
.Name("TreeViewTemplateBiding")
.TemplateId("TreeViewTemplate")
.BindTo((IEnumerable<OrgChart.Models.NodeViewModel>)ViewBag.Tree, (Kendo.Mvc.UI.Fluent.NavigationBindingFactory<TreeViewItem> mappings) =>
{
mappings.For<OrgChart.Models.NodeViewModel>(binding => binding.ItemDataBound((item, node) =>
{
item.Id = node.Id;
item.Text = node.Title;
//item.Expanded = node.Expanded;
})
.Children(node => node.Children));
})
)
There is no 'click' event for kendo tree but there is 'select' event instead of 'click'. You can create event handler like this:
Html.Kendo().TreeView()
.Name("TreeViewTemplateBiding")
.TemplateId("TreeViewTemplate")
.BindTo((IEnumerable<OrgChart.Models.NodeViewModel>)ViewBag.Tree, (Kendo.Mvc.UI.Fluent.NavigationBindingFactory<TreeViewItem> mappings) =>
{
mappings.For<OrgChart.Models.NodeViewModel>(binding => binding.ItemDataBound((item, node) =>
{
item.Id = node.Id;
item.Text = node.Title;
//item.Expanded = node.Expanded;
})
.Children(node => node.Children));
})
.Events(e => e
.Select("onSelect")
)
)
And on Script you can call :
function onSelect(e){
kendoConsole.log("Selecting: " + this.text(e.node));
}
There is demo for more treeview events : http://demos.telerik.com/aspnet-mvc/treeview/events
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments