Hi,
I'm trying to redirect to a controller action and pass the ID of the selected tree node into the controller action.
Ideally, I would like to use some code like this:
And here's what the onSelect would do:
I'm not sure if window.location is the way to do this and would welcome better suggestions. I don't have a form to submit, I just want to go to another page when the user clicks a tree node. Surely I'm missing something here...
Thanks,
bh
I'm trying to redirect to a controller action and pass the ID of the selected tree node into the controller action.
Ideally, I would like to use some code like this:
<div
class
=
"kendo-tree"
>
@(Html.Kendo().TreeView()
.Name(
"treeview"
)
.DataTextField(
"Name"
)
.TemplateId(
"treeview-template"
)
.DataSource(dataSource => dataSource
.Read(read => read.Action(
"DashboardTree"
,
"Home"
))
)
.Events(e => e.Select(
"onSelect"
))
)
</div>
function
onSelect(e) {
var
data = $(
'#treeview'
).data(
'kendoTreeView'
).dataItem(e.node);
//alert("node clicked" + data.id);
window.location = @Url.Action(
"Edit"
,
"Employee"
,
new
{ id = data.id });
}
Thanks,
bh