0
這是我的代碼如下。我需要將onclick鏈接到我的控制器中的Action按鈕。使用Kendo UI Grid,我如何創建一個自定義工具欄,該工具欄有一個鏈接回我的控制器中的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"))
您嘗試過{{url:'/ Home/GetCars'}嗎?或者說,如果你看看@ @ Url.Action('GetCars','Home')'返回什麼,那麼你可以直接粘貼它。 – Brett 2014-10-27 19:52:09
是的,我試過。沒有。我混淆了你對Url.Action('getCars,'Home')返回的說法嗎? – Seth 2014-10-27 19:58:38
這是一個返回字符串的函數。 – Brett 2014-10-27 20:10:36