Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 将ClientTemplate添加到剑道网格UI中的自定义命令_Asp.net Mvc_Razor_Telerik Grid - Fatal编程技术网

Asp.net mvc 将ClientTemplate添加到剑道网格UI中的自定义命令

Asp.net mvc 将ClientTemplate添加到剑道网格UI中的自定义命令,asp.net-mvc,razor,telerik-grid,Asp.net Mvc,Razor,Telerik Grid,这是我的剑道格网代码: @(Html.Kendo().Grid(Model) .Name("paymentGrid") .Columns(columns => { columns.Bound(p => p.AccountName).Title("Account Name"); columns.Bound(p => p.Active).Title("Active").ClientTemplate("<div>#=Acti

这是我的剑道格网代码:

@(Html.Kendo().Grid(Model)
    .Name("paymentGrid")
    .Columns(columns =>
    {
      columns.Bound(p => p.AccountName).Title("Account Name");
      columns.Bound(p => p.Active).Title("Active").ClientTemplate("<div>#=Active ? 'Active' : 'Inactive'#</div>");
      columns.Command(command => command.Custom("DeActivate").Click("deActivatePaymentAccount").Text("DeActivate")).Title("DeActivate");
    })
    .Filterable()
    .Sortable()
    .Pageable(paging => paging.Enabled(true).PageSizes(true).Messages(messages => messages.Empty("No accounts found")))
    .Editable(editable => editable.Mode(GridEditMode.InLine))
    .DataSource(dataSource => dataSource
      .Ajax()
      .ServerOperation(false)
      .Model(model =>
      {
        model.Id(p => p.AccountId);
      })
      .Update(update => update.Action("EditAccount", "Account"))
    )
  )
@(Html.Kendo().Grid(模型)
.名称(“paymentGrid”)
.列(列=>
{
columns.Bound(p=>p.AccountName).Title(“帐户名”);
columns.Bound(p=>p.Active).Title(“Active”).ClientTemplate(“#=Active?”“Active”:“Inactive”#);
columns.Command(Command=>Command.Custom(“DeActivate”)。单击(“deActivatePaymentAccount”)。文本(“DeActivate”)。标题(“DeActivate”);
})
.可过滤()
.Sortable()
.Pageable(分页=>paging.Enabled(true).页面大小(true).消息(消息=>Messages.Empty(“未找到帐户”))
.Editable(可编辑=>Editable.Mode(GridEditMode.InLine))
.DataSource(DataSource=>DataSource
.Ajax()
.ServerOperation(错误)
.Model(Model=>
{
model.Id(p=>p.AccountId);
})
.Update(Update=>Update.Action(“EditAccount”、“Account”))
)
)
问题:
如何将客户端模板添加到自定义命令(停用),以便根据帐户是否处于活动状态切换按钮上的文本?

我认为更改按钮文本的最佳方法是在绑定到单击事件的javascript函数中执行此操作:

    function deActivatePaymentAccount(e) {
        var $btn = $(e.target);
        $btn.text() === "DeActivate" ? $btn.text("Activate") : $btn.text("DeActivate");
        // some other code here
    }

嘿,塞缪尔,谢谢你的回答-我已经用javascript函数完成了。但是,我想像我的另一个绑定列一样使用客户端模板进行活动。您能够解决此问题吗?