我是Kendo的新手,正在尝试向网格添加自定义命令。 我已经持续了示例页面,StackOverflow的,和Telerik的网站,发现多个例子有以下几点:Kendo MVC Razor Grid自定义命令没有动作定义
columns.Command(command =>
{
command.Custom("Details").Text("Show Details").Action("Details", "Billing");
});
当我尝试使用此,我得到以下错误:
'GridCustomActionCommandBuilder' does not contain a definition for 'Action' and the best extension method overload 'UrlHelperExtensions.Action(IUrlHelper, string, object)' requires a receiver of type 'IUrlHelper'
然后,我试过了这个例子从telerik:
columns.Template(@<text>@Html.ActionLink("Edit", "Home", new { id = item.ProductID })</text>);
但得到这个错误:
Cannot convert lambda expression to type 'string' because it is not a delegate type
只是为了确认是什么原因造成的错误,然后拿出ActionLink的,只有使用这样的:
columns.Template(@<text>
<div>help me!!</div>
</text>);
,并得到了同样的错误:
总代码片段看起来是这样的:
@(Html.Kendo().Grid<OrganisationEmployeesViewModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.EmployeeID).Visible(false);
columns.Template(@<text>
<div>help me!!</div>
</text>);
})
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.HtmlAttributes(new { style = "height:550px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Employees_Read", "Organisations"))
)
.Deferred()
)
我使用现有的样本,但不知道什么是错的。
有你在视图中包含了所有必要的kendo脚本引用(可能是布局视图)? – counterflux
@counterflux如上所述,我是剑道新手。我在我的_Layout.cshtml文件中引用了kendo.aspnetmvc.min.js和kendo.all.min.js。我需要添加更多引用吗?我如何添加它们? – MerlinNZ
我有一个捆绑:'〜/ Content/kendo/2016.1.226/kendo.common.min.css〜/ Content/kendo/2016.1.226/kendo.mobile.all.min.css〜/ Content/kendo/2016.1.226/kendo.dataviz.min.css〜/ Content/kendo/2016.1.226/kendo.flat.min.css〜/ Content/kendo/2016.1.226/kendo.dataviz.flat.min.css〜/ Scripts /kendo/2016.1.226/jquery.min.js〜/ Scripts/kendo/2016.1.226/jszip.min.js〜/ Scripts/kendo/2016.1.226/kendo.all.min.js'那我用我的应用。你的代码似乎没有给我错误。也不要忘记在nuget包管理器中添加JQUERY。 – counterflux