我在使用asp.net mvc 4开始使用kendo网格时遇到问题。我有控制器方法将数据传递给视图,但是我正在尝试在kendo网格中查看。我已通过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>
我更改了我的默认布局,但它仍无效。
答案 0 :(得分:1)
至于剑道部分。我知道他们的文档和样本可能更好,事实上他们的样本通常是最糟糕的方式。但是,搜索此网站以获取其他人们拥有的示例和问题。我想你可能会忽略Kendo Grid的重点,需要从头开始。得到一个简单的例子,让它工作,然后展开它。
祝你好运,编码愉快。