为EasyUI的dataGrid单元格增加鼠标移入移出事件

        onLoadSuccess: function (data) {
            $(".datagrid-row").mouseover(function (e) {
                var text = $(this).children("td").eq(1).text();
                var tooltip = "<span id='tooltip'>" + text + "</span>";
                //获取鼠标位置(将鼠标位置写在此处,而非直接写在top,left后面是因为,我在项目中写在了后面,获取不到鼠标坐标的情况。必要时可以使用全局变量!!!)
                var locationX = e.pageX + 10;
                var locationY = e.pageY;
                $("body").append(tooltip);
                $("#tooltip").css({
                    "top": locationY + "px",
                    "left": locationX + "px"
                }).show("fast");
            }).mouseout(function () {
                $("#tooltip").remove();
            }).mousemove(function (e) {
                $("#tooltip").css({
                    "top": locationY + "px",
                    "left": locationX + "px"
                });
            });
        },

利用在dataGrid中,每行都会被加上 datagrid-row 这个特性,为单元格增加些事件。

为grid增加事件最好的方式是直接在jqueryEasyUI的脚本中进行更改,网上也有实例。但是easyUI有几个版本的变化较大,插件内部的JS代码也不尽相同,更改起来较为麻烦。所以就选择了这种比较简单的方法。

原文地址:https://www.cnblogs.com/vichin/p/8493249.html