简体   繁体   English

如何使用Kendo网格自定义命令?

[英]How to use Kendo grid custom command?

I am working on ASP.NET MVC4 application with Kendo UI Grid. 我正在使用Kendo UI Grid开发ASP.NET MVC4应用程序。

And i want to show custom confirmation message for 'Destroy' command.And for that i am using custom command. 我想显示“销毁”命令的自定义确认消息。为此,我正在使用自定义命令。

Below is the piece of the code for that :- 以下是该代码的一部分:

<%:Html.Kendo().Grid<Kendo.Mvc.Examples.Models.EmployeeViewModel>()
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(e => e.FirstName);
        columns.Bound(e => e.LastName);
        columns.Bound(e => e.Title);
        columns.Command(command => command.Custom("ViewDetails").Click("showDetails"));
    })
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("CustomCommand_Read", "Grid"))
     )
%>

Now,i want to add one method in DataSource before call my "ShowDetails" javascript function(custom command onclick function). 现在,我想在调用“ ShowDetails” javascript函数(自定义命令onclick函数)之前在DataSource中添加一个方法。

So how can i add my action in DataSource section like - Read,Create,Destory ? 那么,如何在“数据源”部分中添加我的操作,例如-Read,Create,Destory?

you can try do this 你可以尝试做

.Read(read => read.Action("CustomCommand_Read", "Grid").Data("JS_function"))

in this case you call function JS_function and pass parameter that return you this function into your controller action(don't forger add to your CustomCommand_Read parameter) 在这种情况下,您调用函数JS_function并传递参数,该参数将使您将此函数返回到控制器操作中(不要伪造添加到CustomCommand_Read参数中)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM