我在使用 asp.net mvc 4 开始剑道网格时遇到了麻烦。我有控制器方法,它正在传递数据以查看效果很好,但我试图在剑道网格中查看。我通过 ManageNuGet 添加了参考。
这是我的代码
public ActionResult createNewStore()
{
return View();
}
[HttpPost]
public ActionResult createNewStore(Store storeModel)
{
var db = new AppContext();
var Store = new Store { address = storeModel.address, postcode = storeModel.postcode, city = storeModel.city, Country = storeModel.Country };
db.Stores.Add(Store);
db.SaveChanges();
return View();
}
public ActionResult viewStores()
{
var db = new AppContext();
var query = from b in db.Stores
orderby b.storeID
select b;
return View(query.ToList());
}
public void Delete()
{
}
查看代码
@model IEnumerable <MyProject_04.Models.Store>
@{
ViewBag.Title = "viewStores";
}
<link href="~/Content/kendo/2012.3.1114/kendo.common.min.css" rel="stylesheet" />
<link href="~/Content/kendo/2012.3.1114/kendo.default.min.css" rel="stylesheet" />
@Scripts.Render("~/bundles/jquery")
<script src="~/Scripts/kendo/2012.3.1114/kendo.web.min.js"></script>
<script type="text/javascript">
$(function () {
$(".delete-link").click( function(e){
e.preventDefault();
if (confirm("do you want to delete record?")) {
$(this).closest("tr").hide("slow");
}
return false;
});
$("#grid").kendoGrid();
});
</script>
<h2>View All the list of stores</h2>
<table id="grid">
<thead>
<tr>
<th>Store ID</th>
<th>Address</th>
<th>post Code</th>
<th>City</th>
<th>Country</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>@Html.DisplayFor(modelItem=> item.storeID)</td>
<td>@Html.DisplayFor(modelItem=> item.address)</td>
<td>@Html.DisplayFor(modelItem=> item.postcode)</td>
<td>@Html.DisplayFor(modelItem=> item.city)</td>
<td>@Html.DisplayFor(modelItem=> item.Country)</td>
<td>@Html.ActionLink("Delete", "Delete", new { id = item.storeID }, new { @class ="delete-link"})</td>
</tr>
}
</tbody>
</table>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>@ViewBag.Title - My ASP.NET MVC Application</title>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta name="viewport" content="width=device-width" />
@Styles.Render("~/Content/css")
<link href="~/Content/kendo/2012.3.1114/kendo.common.min.css" rel="stylesheet" />
<link href="~/Content/kendo/2012.3.1114/kendo.default.min.css" rel="stylesheet" />
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
<div id="container">
<!--------------Header------------------->
<div id="header">
<div class="content-wrapper">
<div class="float-left">
<p class="site-title">@Html.ActionLink("MVC Movie", "Index", "Home")</p>
</div>
</div>
</div>
<!--------------Body------------------->
<div id="body">
@Scripts.Render("~/bundles/jquery")
<script src="~/Scripts/kendo/2012.3.1114/kendo.web.min.js"></script>
@RenderSection("featured", required: false)
<section class="content-wrapper main-content clear-fix">
@RenderBody()
</section>
</div>
<!--------------Footer------------------->
<div id="footer">
<div class="content-wrapper">
<div class="float-left">
<p>© @DateTime.Now.Year - My ASP.NET MVC Application</p>
</div>
</div>
</div>
</div>
@Scripts.Render("~/bundles/jquery")
@RenderSection("scripts", required: false)
</body>
</html>
我已经更改了我的默认布局,但它仍然无法正常工作。