Kendo MVC Razor 网格自定义命令没有操作定义

Kendo MVC Razor Grid Custom Command does not have Action Definition

我是 Kendo 的新手,正在尝试向网格添加自定义命令。 我浏览了示例页面、Whosebug 和 Telerik 的网站,发现了多个具有以下内容的示例:

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()
)

我正在使用现有样本,但不知道哪里出了问题。

我找到了让它工作的方法:

        columns.Template("<a href='" +
            Url.Action("ControllerAction", "Controller") +
            "?Parameter=#= RecID #'" +
        ">DisplayText</a>");

这也可以像这样应用于绑定列:

        columns.Bound(p => p.Name).ClientTemplate("<a href = '" +
            Url.Action("Details", "Employees") +
            "/#= EmployeeID #'" +
        ">#=Name#</a>");

如果您想要在 Kendo 网格上进行自定义工具栏操作: 我正在使用标准 bootstrap 类 来应用默认值:

    .ToolBar(t => t.ClientTemplate("<a class='k-button k-button-icontext k-grid-add' href='" +
            Url.Action("OrganisationCreate", "Employees", new { OrganisationId = Model.OrganisationID }) +
            "'><span class='k-icon k-add'></span>Add new Employee</a>") )