我想在KendoUI网格对象中单击网格列标题时将鼠标连接起来(左右键单击)事件。只是想知道是否有人有任何想法如何去做?
答案 0 :(得分:2)
您可以使用mousedown事件:
$(document).on("mousedown", " .k-header", function(e){
var fieldname = $(this).data("field");
switch (e.which) {
case 1:
alert('Left Mouse button pressed. Field = ' + fieldname);
break;
case 2:
alert('Middle Mouse button pressed. Field = ' + fieldname);
break;
case 3:
alert('Right Mouse button pressed. Field = ' + fieldname);
break;
}
});
kendo ui网格为标题单元格分配一类k-header,字段名称存储在data-attribute中(data-field ="")。
<强> DEMO 强>