【问题标题】:add ClientTemplate to custom command in kendo grid UI将 ClientTemplate 添加到剑道网格 UI 中的自定义命令
【发布时间】:2012-09-20 20:52:58
【问题描述】:

这是我的剑道网格代码:

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

问题: 如何将客户端模板添加到我的自定义命令(停用),以便我可以根据帐户是否处于活动状态来切换按钮上的文本?

【问题讨论】:

  • 你能解决这个问题吗?

标签: asp.net-mvc razor telerik-grid


【解决方案1】:

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

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

【讨论】:

  • 嘿 Samuel,感谢您的回答 - 我已经使用 javascript 函数完成了此操作。但是,我想像我的其他绑定列 Active 一样使用客户端模板进行操作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-09-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-01
  • 2013-06-27
  • 2023-03-10
相关资源
最近更新 更多