easyui 修改单元格内容_EasyUI Datagrid 鼠标悬停显示单元格内容

这篇博客介绍了如何使用EasyUI的tooltip.js文件来实现在Datagrid中鼠标悬停时显示单元格内容的功能。通过初始化组件、设置选项和调整定位,实现了当鼠标悬浮在目标单元格上时,显示对应的内容,同时提供了内容自定义、颜色配置和位置调整的灵活性。
摘要由CSDN通过智能技术生成

js 文件 Jquery.easyui.tooltip.js:

(function ($) {

function init(target) {var opt = $.data(target, "tips").options;var tips = $(".easyui-tips-hover");if (tips.length == 0) {

tips= $("

}

opt.content= (opt.content || $(target).attr("tooltip"));

tips.appendTo("body");

$(target).css("color", opt.wrapColor);

$(target).hover(function () {

tips.html(opt.content);var offset =$(target).offset();//var outerWidth = tips.outerWidth();//if (outerWidth > 200) {//tips.width(200);//}

var scrollTop =$(document).scrollTop();var tipsHeight =tips.outerHeight();var outerWidth =tips.outerWidth();var targetHeight =$(target).outerHeight();var top = offset.top -tipsHeight;var left =offset.left;if ((offset.top - scrollTop) < top || top < 100) {

top= offset.top +targetHeight;

}var bodyClienWidth = $("body")[0].clientWidth;if ((bodyClienWidth - left)

left= bodyClienWidth -outerWidth;

}

tips.css({ top: top, left: left }).show();

}, function () {

tips.hide().width("auto");

});

}

$.fn.tips= function (options, params) {if (typeof options === 'string') {return $(this).tips.methods[options].call(this, params);

}

options= options ||{};return this.each(function () {var opt = $.data(this, "tips");if(opt) {

$.extend(opt.options, options);

}else{

$.data(this, "tips", {

options: $.extend({}, $.fn.tips.defaults, options)

});

init(this);

}

});

};

$.fn.tips.defaults={

cls:"",

content:null,

wrapColor:"blue"};if($.parser) {

$.parser.plugins.push('tips')

}

})(jQuery);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值