以下是我的代码。我需要将onclick链接到我的控制器中的Action,用于工具栏按钮。
<script>
$(document).ready(function() {
var grid = $("#grid").kendoGrid({
dataSource: {
transport: {
read: { url: '@Url.Action("GetCars", "Home")' }
pageSize: 20,
serverPaging: true,
serverSorting: true,
serverFiltering: true
},
toolbar: [ { name: "create", text: "Add a new car" }],
height: 550,
sortable: true,
pageable: true,
columns: [
{ field: "ProductID", title: "Product ID", width: 100 },
{ field: "ProductName", title: "Product Name" },
{ field: "UnitPrice", title: "Unit Price", width: 150 },
{ field: "QuantityPerUnit", title: "Quantity Per Unit" }
]
});
</script>
我总是在剃刀中做到的方式是:
.ToolBar(toolbar => toolbar.Custom().Text("Add new car").Action("Create", "Home"))
答案 0 :(得分:0)
我找到了问题的答案。
toolbar: [{ name:"create", template: "<input type='submit' value='Add
new' onclick=\"location.href='@Url.Action("Create", "Home")'\" />" }],