我正在使用kendo MVC网格创建MVC 5应用程序。我从数据库中提取的数据没有绑定到网格。当我检查开发人员控件时看到错误Uncaught ReferenceError:未定义kendo。我还注意到网格中指定的动作方法没有触发。看起来像是一个jquery问题。
我检查了所有引用并完成了运行kendo MVC的基本设置。不确定是什么问题
@model IEnumerable<CC.GRP.MCRequest.Models.TeamIn>
@(Html.Kendo().Grid<CC.GRP.MCRequest.Models.TeamIn>()
.Name("GridTeam")
.Columns(columns =>
{
columns.Bound(o => o.TeamID).Groupable(false);
columns.Bound(o => o.CountryCode);
columns.Bound(o => o.TeamName);
columns.Bound(o => o.TeamDescription);
})
.Pageable()
.Sortable()
.Filterable()
.Scrollable()
.Groupable()
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("Team_Read", "Admin"))
)
)
控制器代码
public ActionResult Team()
{
return View();
}
public ActionResult Team_Read([DataSourceRequest]DataSourceRequest request)
{
return Json(mcrRepository.GetTeams().ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}
Bundle.config
public class BundleConfig
{
// For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/kendo").Include(
"~/ Scripts/kendo/2017.1.223/jquery.min.js",
"~/ Scripts/kendo/2017.1.223/jszip.min.js",
"~/Scripts/kendo/2017.1.223/kendo.all.min.js",
"~/Scripts/kendo/2017.1.223/kendo.aspnetmvc.min.js"));
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.min.js",
"~/Scripts/respond.js"));
bundles.Add(new StyleBundle("~/Content/custom/css").Include(
"~/Content/custom/app.css"));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/Site.css",
"~/Content/bootstrap.css"
));
bundles.Add(new StyleBundle("~/Content/kendo/css").Include(
"~/Content/kendo/2017.1.223/kendo.common.min.css",
"~/Content/kendo/2017.1.223/kendo.mobile.all.min.css",
"~/Content/kendo/2017.1.223/kendo.dataviz.min.css",
"~/Content/kendo/2017.1.223/kendo.default.min.css",
"~/Content/kendo/2017.1.223/kendo.dataviz.default.min.css"
));
bundles.IgnoreList.Clear();
}
Layout.cshtm
<!DOCTYPE html>
<html>
<head>
<title>@ViewBag.Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0,user-scalable=no">
@Styles.Render("~/Content/kendo/css")
@Styles.Render("~/Content/css")
@Styles.Render("~/Content/custom/css")
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
<header>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="#"><img src="~/Images/Computacenter.png" /> </a>
<h1>MCR</h1>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right text-center">
<li><a href="@Url.Action("Team", "Admin")"><span class="glyphicon glyphicon glyphicon-home" aria-hidden="true"></span><p>Home</p></a></li>
<li><a href="@Url.Action("Team", "Admin")"><span class="glyphicon glyphicon glyphicon-file" aria-hidden="true"></span><p>Requests</p></a></li>
<li><a href="@Url.Action("Team", "Admin")"><span class="glyphicon glyphicon glyphicon-tasks" aria-hidden="true"></span><p>Activities</p></a></li>
<li><a href="@Url.Action("Team", "Admin")"><span class="glyphicon glyphicon glyphicon-file" aria-hidden="true"></span><p>Reports</p></a></li>
<li class="hideli"><a href="@Url.Action("Team", "Admin")"><span class="glyphicon glyphicon glyphicon-cog" aria-hidden="true"></span><p>Admin</p></a></li>
<li><a href="@Url.Action("Team", "Admin")"><span class="glyphicon glyphicon glyphicon-save" aria-hidden="true"></span><p>Save View</p></a></li>
</ul>
</div>
</div>
</nav>
</header>
<div id="body">
@RenderBody()
</div>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@Scripts.Render("~/bundles/kendo")
@RenderSection("scripts", required: false)
</body>
</html>
答案 0 :(得分:0)
这已得到修复。这就像关闭和打开视觉工作室一样简单。