【问题标题】:add event listener for kendo grid command button为剑道网格命令按钮添加事件监听器
【发布时间】:2013-07-31 11:05:20
【问题描述】:

我正在开发 ASP.NET MVC4 应用程序。我在其中使用 Kendo UI 控件。

我正在使用 Kendo Grid。我想在 Kendo Grid 工具栏的“添加新项目”按钮上添加事件监听器。

下面是Grid命令按钮的一段代码:

 .ToolBar(commands =>
               {
                   commands.Create();
                   commands.Save();
           })

我想覆盖它的点击事件。实际上我想检查它的点击事件的一些条件。如果条件返回真,那么我希望这个按钮应该启用,否则它应该被禁用。

我试图用下面的一些代码覆盖它,但它不起作用。

例子:

1)  '$(".k-button.k-button-icontext.k-grid-add").bind("click", function () {   
     alert('add link event');
 });

2)   $(".k-grid-Add").on('click',function () {    
     alert("Hello");
});

 3)   $(".k-button.k-button-icontext.k-grid-add").on("click", function () {   
     alert('add link event');
 }); '

但以上都不起作用。

谁能给我建议?

谢谢

【问题讨论】:

    标签: events overriding toolbar kendo-grid commandbutton


    【解决方案1】:

    使用工具栏模板来创建您的命令。这允许您指定 onClick 事件。

    .ToolBar(commands => 
     commands.Template("<a class='k-button k-button-icontext' onclick='customCommand()' href='#'></span>Create</a>"))
    

    然后你可以在 js 函数 customCommand() 中进行检查。

    有关工具栏模板的更多信息:http://docs.kendoui.com/api/web/grid#configuration-toolbar.template

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-16
      • 2012-11-23
      相关资源
      最近更新 更多