@(智能感知器无法识别Html.Kendo()

时间:2016-08-03 14:12:20

标签: asp.net-mvc kendo-grid kendo-asp.net-mvc

我使用的是Kendo.Mvc dll,以下是我的.cshtml

    @using Kendo.Mvc.UI
    @model SupplierPortal.RedirectionApp.Models.SiteDetailViewModel
    @using System.Web.Optimization
    @{
        ViewBag.Title = "Index";
        Layout = null;
    }
<script src="http://code.jquery.com/jquery-1.11.1.js" type="text/javascript"></script>
@*<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.20/jquery-ui.min.js" type="text/javascript"></script>*@
@*<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.2.714/styles/kendo.common-bootstrap.min.css" />*@
<link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.2.714/styles/kendo.common-bootstrap.min.css" />
<link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.2.714/styles/kendo.bootstrap.min.css" />
<link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.2.714/styles/kendo.default.mobile.min.css" />
<script src="//kendo.cdn.telerik.com/2016.2.714/js/jquery.min.js"></script>
<script src="//kendo.cdn.telerik.com/2016.2.714/js/kendo.all.min.js"></script>
<script src="http://kendo.cdn.telerik.com/2016.2.714/js/kendo.aspnetmvc.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
    <div>
        @(Html.Kendo().Grid<SupplierPortal.RedirectionApp.Models.SiteDetailViewModel>()
                      .Name("Grid")
                      .Columns(columns =>
                      {
                          columns.Bound(p => p.name).Title("Name");
                          columns.Bound(p => p.gender).Title("Gender");
                          columns.Bound(p => p.designation).Title("Designation").Width("300px");
                          columns.Bound(p => p.department).Title("Department").Width("300px");
                      })

                      .Editable(editable => editable.Mode(GridEditMode.InLine))
                      .Navigatable()
                      .Pageable()
                      .Sortable()
                      .Scrollable()
                      .DataSource(dataSource => dataSource // Configure the grid data source
                      .Ajax()
                      .Model(model =>
                      {
                          //model.Id(x => x.id);
                      })
                          .Read(read => read.Action("Employee_Read", "Home")) // Set the action method which will return the data in JSON format
                       )
        )
    </div>

以下是我的控制器

public ActionResult Index([DataSourceRequest]DataSourceRequest request)
{
    string nasaUserId = "vlc00072";
    var _prd = _redirectionService.GetSiteDetailsForAppUser(nasaUserId);
    _siteDetailViewModel.SiteDetailList = _prd;
    return Json(_siteDetailViewModel, JsonRequestBehavior.AllowGet);
}

我还在Kendo.MVC中添加了Views Web.Config引用,如下所示

<namespaces>
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Routing" />
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Routing" />
    <add namespace="SupplierPortal.RedirectionApp" />
    <add namespace="Kendo.Mvc" />

</namespaces>

并在主web.config文件中

  <system.web>   
<compilation debug="true" targetFramework="4.5.2" >
<assemblies>       
    <add assembly="Kendo.Mvc" />
  </assemblies>
</compilation>
<httpRuntime targetFramework="4.5.2" />
<httpModules>
  <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
</httpModules>

有人可以让我告诉我错误的地方以及为什么剃刀不会识别@Html.Kendogrid()而且我也将dll包含在参考中。

1 个答案:

答案 0 :(得分:0)

您必须使用Telerik团队提供的Kendo.mvc.dll。我通过从nuget安装Kendo.MVC遇到了同样的问题,但它没有认识到我已经添加了由Telerik团队提供的.dll。现在它正在运作。 Here is the link要下载试用版,您会在 C:\ Program Files(x86)\ Telerik \ UI for ASP.NET MVC Q2 2016 \ wrappers \ aspnetmvc \ Binaries中找到Kendo.Mvc.dll 安装后的位置。