下图显示了 Kendo Grid 的每一行上都有一个自定义编辑按钮的小按钮,我使用以下代码实现了该按钮。
command: [{
name: "MyEdit",
click: myFunction,
template: "<a id= 'myEdit' class='k-grid-MyEdit k-button'><span class='k-icon k-i-edit'></span></a>"
}]
function myFunction(e) {
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
}
自定义按钮点击事件工作正常,但我的要求是 - 此按钮的“onmouseover”、“mouseenter”或“onhover”事件。 我尝试谷歌搜索,发现除了点击事件之外没有其他事件。 我只需要内置的命令按钮事件,例如“单击”就是这个例子。
如果我的实现有问题,请给我一个解决方案或纠正我。
最佳答案
Kendo 不提供任何其他事件类型,但click
。需要自己绑定(bind)。这很简单,只需将事件绑定(bind)到按钮类过滤的网格元素即可:
$(grid.element).on("mouseover mouseenter", ".k-grid-MyEdit", function(e) {
console.log("Button event type: ", e.type);
$(this).click();
});
Demo .
关于javascript - Kendo Grid 自定义按钮的 mouseover 或 mouseenter 或 onhover 事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49794095/