剑道MVC网格:创建自定义命令按钮并传递参数 [英] Kendo MVC Grid: Creating a Custom command button and passing parameters

查看:353
本文介绍了剑道MVC网格:创建自定义命令按钮并传递参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个自定义命令按钮来触发一个自定义删除功能。我需要我的模型的ID传递给我的自定义删除功能。你会发现,我想在一个静态通过'5'是一个测试,但我想在该行的ID通过。

任何帮助将大大AP preciated。

  @(Html.Kendo()。网格(模型)
。名称(网格)
.Columns(列=>
{
    columns.Bound(p值=> p.Name).WIDTH(240);
    columns.Bound(P => p.City).WIDTH(170);
    columns.Bound(P => p.State).WIDTH(170);
    columns.Command(命令=>
    {
        command.Edit();
        command.Custom(删除)点击(PropertyPage.DeleteProperty)HtmlAttributes(新{@Id = 5})。
        })宽度(166)。
    })
    .Scrollable()
    .Editable(编辑= GT; editable.Mode(GridEditMode.InLine))
    .DataSource(数据源=>数据源
        阿贾克斯()
        。型号(型号=> model.Id(P => p.Id))
        .Read(读=> read.Action(PropertyRead,房产))
        .Update(更新=> update.Action(更新,房产))
        .Destroy(更新=> update.Action(删除,房产))
))


解决方案

这应该送指定的任何数据项:

  command.Custom(删除)SendDataKeys(真)。点击(PropertyPage.DeleteProperty);

DataKeys在DataSource部分指定的:

  .DataSource(数据源=>数据源
    阿贾克斯()
    。型号(型号=> model.Id(P => p.Id))//这是你的数据键
    .Read(读=> read.Action(PropertyRead,房产))
    .Update(更新=> update.Action(更新,房产))
    .Destroy(更新=> update.Action(删除,房产))

我也发现了剑道的网站页面。它帮了我,当我有一个类似的问题:
<一href=\"http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/migration/widgets/grid#editing\">http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/migration/widgets/grid#editing

希望这有助于!

I'm trying to create a custom command button to fire a custom delete function. I need to pass the ID of my model to my custom delete function. You'll notice that I'm trying to pass in a static '5' as a test but I would like to pass in the ID of the row.

Any help would be greatly appreciated.

@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
    columns.Bound(p => p.Name).Width(240);
    columns.Bound(p => p.City).Width(170);
    columns.Bound(p => p.State).Width(170);
    columns.Command(command =>
    {
        command.Edit();
        command.Custom("Delete").Click("PropertyPage.DeleteProperty").HtmlAttributes(new { @Id = 5 });
        }).Width(166);
    })
    .Scrollable()
    .Editable(editable => editable.Mode(GridEditMode.InLine))
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model => model.Id(p => p.Id))
        .Read(read => read.Action("PropertyRead", "Property"))
        .Update(update => update.Action("Update", "Property"))
        .Destroy(update => update.Action("Delete", "Property"))
))

解决方案

This should send any Data keys specified:

command.Custom("Delete").SendDataKeys(true).Click("PropertyPage.DeleteProperty");

DataKeys are specified in the DataSource section:

    .DataSource(dataSource => dataSource
    .Ajax()
    .Model(model => model.Id(p => p.Id))  // THIS IS YOUR DATA KEY
    .Read(read => read.Action("PropertyRead", "Property"))
    .Update(update => update.Action("Update", "Property"))
    .Destroy(update => update.Action("Delete", "Property"))

I also found this page on Kendo's site. It helped me out when I was having a similar issue: http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/migration/widgets/grid#editing

Hope this helps!

这篇关于剑道MVC网格:创建自定义命令按钮并传递参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆