第一种方式:
.js 定义函数
<script type="text/javascript">
//格式化单元格提示信息
function formatCellTooltip(value){
return "<span title='" + value + "'>" + value + "</span>";
}
</script> 、调用函数
 <table class="easyui-datagrid" style="width:400px;height:250px"
    data-options="url:'datagrid_data.json',fitColumns:true,singleSelect:true">
    <thead>
      <tr>
      <th data-options="field:'itemid',width:80,halign:'center',formatter:formatCellTooltip">Item ID</th>
      </tr>
    </thead>
 </table>

源码:jquery-easyui-1.3.6.zip    例子是:jquery-easyui-1.3.6\demo\datagrid\formatter.html

 第二种方式:
1.html
<table id="dg">
</table> 2.js
$('#dg').datagrid({
fitColumns: true,
nowrap: true,
striped: true,
rownumbers: true,
pagination: true,
singleSelect: true,
columns: [[
{ field: "itemid", title: 'Item ID', width:,halign:'center', formatter: function (value) {
return "<span title='" + value + "'>" + value + "</span>";
}
}]]
}); 源码:jquery-easyui-1.3.6.zip 例子是:jquery-easyui-1.3.6\demo\datagrid\formatter2.html

其他方式:

1.例如,扩展 jQuery EasyUI tips

js 文件 Jquery.easyui.tooltip.js:

(function ($) {
function init(target) {
var opt = $.data(target, "tips").options;
var tips = $(".easyui-tips-hover");
if (tips.length == ) {
tips = $("<div/>").css({
"position": "absolute",
"border-radius": "5px",
"-webkit-border-radius": "5px",
"-moz-border-radius": "5px",
"padding": "5px",
"background": "#fff",
"display": "none",
"border": "1px solid gray"
}).hide().addClass("easyui-tips-hover").addClass(opt.cls);
} 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 < ) {
top = offset.top + targetHeight;
}
var bodyClienWidth = $("body")[].clientWidth;
if ((bodyClienWidth - left) < outerWidth) {
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);

使用:

在jquery 的datagrid的onLoadSuccess方法中

html:

<table id="dg"></table>

js :

$(function () {
var _grid = $('#dg').datagrid({
url: 'products.json',
columns: [[
{ field: 'productid', title: 'productid', width: },
{ field: 'productname', title: 'productname', width: },
{ field: 'price', title: 'Price', width: , align: 'right' }
]],
onLoadSuccess: function () { var tableTd = $('div.datagrid-body td[field="productname"]'); //productname是列名
tableTd.each(function () {
var $this = $(this);
var index = $this.parent('tr').attr('datagrid-row-index');
var rows = _grid.datagrid('getRows');
var currentRow = rows[index];
var content = '<div style=" max-width:700px;word-break: break-all; word-wrap: break-word;">' + currentRow.productname + '</div>'; //productname是列名
$this.tips({ content: content, wrapColor: 'black' });
});
}
});
}); 源码:jquery-easyui-1.3.6.zip 例子是:jquery-easyui-1.3.6\demo\datagrid\tips.html

2.当然还有各种jQuery tips插件

EasyUI Datagrid 鼠标悬停显示单元格内容的更多相关文章

  1. EasyUI Datagrid 鼠标悬停显示单元格内容 复制代码

    EasyUI Datagrid 鼠标悬停显示单元格内容 ,halign:, align: 0 « 上一篇:LINQ to Entities 中的查询» 下一篇:去掉字符串中的非数字字符 posted ...

  2. EasyUI的Datagrid鼠标悬停显示单元格内容

    功能描述:table鼠标悬停显示单元格内容 1.js函数 function hoveringShow(value) { return "<span title='" + va ...

  3. easyUi datagrid鼠标经过提示单元格内容

    此文章是基于 EasyUI+Knockout实现经典表单的查看.编辑 一. jquery.cellTip.js /** * 扩展两个方法 */ using('datagrid', function() ...

  4. EXTJS 4.2 实现 gridpanel 鼠标悬停单元格以提示信息的方式显示单元格内容。

    由于gridpanel的单元格里的文字太多时候,都由省略号代替,就想实现如题的功能,经过反复实验,终于搞定了!直接上代码: me.on('itemmouseenter', function (view ...

  5. qtableview 鼠标划过单元格弹出标签显示单元格内容

    QStandardItem *item = new QStandardItem(show_content); infoTableModel->setItem(1, 1, item); item- ...

  6. EasyUI datagrid单元格文本超出显示省略号,鼠标移动到单元格显示文本

    nowrap : true;  是前提 $('#×××').datagrid({ nowrap : true,//设置为true,当数据长度超出列宽时将会自动截取 }); 省略号样式: <sty ...

  7. C# DataGridView在单元格提示里(ToolTip)显示完整的单元格内容

    当单元格内容太多时,则会忽略后面的内容 解决方案: 添加Dgv鼠标移到单元格事件时,设置当前单元格的ToolTipText属性内容为当前单元格内容 void From_Load(object send ...

  8. 获取wpf datagrid当前被编辑单元格的内容

    原文 获取wpf datagrid当前被编辑单元格的内容 确认修改单元个的值, 使用到datagrid的两个事件 开始编辑事件 BeginningEdit="dataGrid_Beginni ...

  9. LaTex: 表格单元格内容 分行显示/换行

    问题:如何同时让表格同一行一个单元格的文字能垂直居中?比如说文字超长超出页面范围需要分行显示 答:(来源于smth) 方案一: \newcommand{\tabincell}[2]{\begin{ta ...

随机推荐

  1. Sublime Text中安装插件来实现px与rem间的换算

    今天在群里无意中看到了群友分享的一篇关于移动端的文章.里面其他内容我倒不大感兴趣,反而是rem让我提起了兴趣. 首先来谈一下rem,rem是CSS3中新增加的一个单位值,它和em单位一样,都是一个相对 ...

  2. java字符串,包,数组及空心正方形,菱形的实例

    一.数组:相同类型的多个对像引用类型:所有的类,接口,数组,int[] ints(变量名) = new int[3]new:指的是在内存空间重新开辟一块区域 String s1 = "abc ...

  3. CJOJ 1976 二叉苹果树 / URAL 1018 Binary Apple Tree(树型动态规划)

    CJOJ 1976 二叉苹果树 / URAL 1018 Binary Apple Tree(树型动态规划) Description 有一棵苹果树,如果树枝有分叉,一定是分2叉(就是说没有只有1个儿子的 ...

  4. MongoDB数据库文档操作

    前面的话 本文将详细介绍MongoDB数据库关于文档的增删改查 数据类型 在介绍文档操作之前,首先要了解MongoDB的数据类型 MongoDB支持许多数据类型,包括 1.字符串 - 这是用于存储数据 ...

  5. 解决win10注册错误 错误代码0x8002801c

    使用win10的过程中经常碰到各种注册错误,让人抓狂!!! 现在分享一个完美的解决方法(非原创): 最简洁的办法是:1.自行将msinet.ocx(win10系统64位)组件复制到C:\Windows ...

  6. JavaScript获取鼠标位置的三种方法

    在一些DOM操作中我们经常会跟元素的位置打交道,鼠标交互式一个经常用到的方面,令人失望的是不同的游览器下会有不同的结果甚至是有的游览器下没结果,这篇文章就鼠标点击位置坐标获取做一些简单的总结. 获取鼠 ...

  7. Java 学习内容总结

    最近对Core Java基础做了一些学习.有自己的见解,也有别人的总结,供大家参考. 1 实现多线程的方式有几种? 其实这个问题并不难,只是在这里做一个总结.一共有三种. 实现Runnable接口,并 ...

  8. 【Django】url传递参数

    1.  url传递参数的特殊字符 在压缩后,可能出现  +  -  = 空格  这类特殊字符,需要在传递前进行url编码  urllib.enquote(string) 获取参数后 urllib.un ...

  9. [BZOJ 2500] 幸福的道路

    照例先贴题面(汪汪汪) 2500: 幸福的道路 Time Limit: 20 Sec  Memory Limit: 256 MBSubmit: 368  Solved: 145[Submit][Sta ...

  10. 完整版百度地图点击列表定位到对应位置并有交互动画效果demo

    1.前言 将地图嵌入到项目中的需求很多,好吧,我一般都是用的百度地图.那么今天就主要写一个完整的demo.展示一个列表,点击列表的任一内容,在地图上定位到该位置,并有动画效果.来来来,直接上demo  ...