如何在Kendo UI中单击自定义工具栏时调用函数? [英] How to call a function when custom toolbar is clicked in Kendo UI?

查看:199
本文介绍了如何在Kendo UI中单击自定义工具栏时调用函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个自定义工具栏。这是我的代码:

I want to create a custom toolbar. Here is my code:

toolbar:[{
    text: "Go to Add User Page",
    className: "k-grid-custom",
    imageClass: "k-add"
}],

function createUser(){
    alert('Hello World');
}

我想调用名为createUser的函数,当这个按钮(自定义工具栏)是点击。如何使它成为可能?

I want to call the function named createUser when this button(custom toolbar) is clicked. How to make it possible?

推荐答案

function test(e){
      return '<a class="k-button" href="#" id="toolbar-add_user" onclick="test_fn()">Add User</a>';
 };
function test_fn(){
        window.location = "http://www.google.com";
};
 toolbar:[{
        name:'add_user',
        template:'#= test()#'
}],




  1. 首先,我必须创建一个能够自定义按钮并添加onclick事件的功能。

  2. 然后我必须制作一个新功能来听取这个事件。

这篇关于如何在Kendo UI中单击自定义工具栏时调用函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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