How can I invoke an edit controller from a grid? I have tried adding a custom command with an Action("Edit","Customers") but there does not seem to be a way to pass the CustomerID to the action. I got the javascript code from the sample custom command grom the grid demo, but I don't seem to be able to make it work. This is what I have, but it doesn't seem to execute the click.
@model IEnumerable<LightRouteDB.Customer>
@{
ViewBag.Title =
"Customer List"
;
}
@(
Html.Kendo().Grid(Model)
.Name(
"CustomerGrid"
)
.Pageable()
.Sortable()
.Filterable()
.Columns(cols =>
{
cols.Bound(c => c.CustomerNum).Width(100).Groupable(
false
);
cols.Bound(c => c.CustomerName).Width(200);
cols.Bound(c => c.BillAddr1).Width(200).Title(
"Address"
);
cols.Bound(c => c.BillCity).Width(100).Title(
"City"
);
cols.Bound(c => c.TotalDue).Format(
"{0:c}"
).Title(
"Balance"
);
cols.Command(cmd => cmd.Custom(
"Edit"
).Text("Edit").Click(
"editCustomer"
));
})
)
<script type=
"text/javascript"
>
function editCustomer(e) {
e.preventDefault();
var dataItem =
this
.dataItem($(e.currentTarget).closest(
"tr"
));
window.nav(
"/customers/edit/"
+ dataItem.CustomerID);
}
</script>