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

第一种方式:
.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 </span>= (opt.content || $(target).attr(<span style="color: #800000;">"</span><span style="color: #800000;">tooltip</span><span style="color: #800000;">"</span><span style="color: #000000;">));
tips.appendTo(</span><span style="color: #800000;">"</span><span style="color: #800000;">body</span><span style="color: #800000;">"</span><span style="color: #000000;">); $(target).css(</span><span style="color: #800000;">"</span><span style="color: #800000;">color</span><span style="color: #800000;">"</span><span style="color: #000000;">, opt.wrapColor); $(target).hover(function () {
tips.html(opt.content);
</span><span style="color: #0000ff;">var</span> offset =<span style="color: #000000;"> $(target).offset();
</span><span style="color: #008000;">//</span><span style="color: #008000;">var outerWidth = tips.outerWidth();
</span><span style="color: #008000;">//</span><span style="color: #008000;"> if (outerWidth > 200) {
</span><span style="color: #008000;">//</span><span style="color: #008000;"> tips.width(200);
</span><span style="color: #008000;">//</span><span style="color: #008000;"> }</span>
<span style="color: #0000ff;">var</span> scrollTop =<span style="color: #000000;"> $(document).scrollTop();
</span><span style="color: #0000ff;">var</span> tipsHeight =<span style="color: #000000;"> tips.outerHeight();
</span><span style="color: #0000ff;">var</span> outerWidth =<span style="color: #000000;"> tips.outerWidth(); </span><span style="color: #0000ff;">var</span> targetHeight =<span style="color: #000000;"> $(target).outerHeight();
</span><span style="color: #0000ff;">var</span> top = offset.top -<span style="color: #000000;"> tipsHeight;
</span><span style="color: #0000ff;">var</span> left =<span style="color: #000000;"> offset.left; </span><span style="color: #0000ff;">if</span> ((offset.top - scrollTop) < top || top < <span style="color: #800080;">100</span><span style="color: #000000;">) {
top </span>= offset.top +<span style="color: #000000;"> targetHeight;
}
</span><span style="color: #0000ff;">var</span> bodyClienWidth = $(<span style="color: #800000;">"</span><span style="color: #800000;">body</span><span style="color: #800000;">"</span>)[<span style="color: #800080;">0</span><span style="color: #000000;">].clientWidth;
</span><span style="color: #0000ff;">if</span> ((bodyClienWidth - left) <<span style="color: #000000;"> outerWidth) {
left </span>= bodyClienWidth -<span style="color: #000000;"> outerWidth;
}
tips.css({ top: top, left: left }).show();
}, function () {
tips.hide().width(</span><span style="color: #800000;">"</span><span style="color: #800000;">auto</span><span style="color: #800000;">"</span><span style="color: #000000;">);
});
} $.fn.tips </span>= function (options, <span style="color: #0000ff;">params</span><span style="color: #000000;">) {
</span><span style="color: #0000ff;">if</span> (<span style="color: #0000ff;">typeof</span> options === <span style="color: #800000;">'</span><span style="color: #800000;">string</span><span style="color: #800000;">'</span><span style="color: #000000;">) {
</span><span style="color: #0000ff;">return</span> $(<span style="color: #0000ff;">this</span>).tips.methods[options].call(<span style="color: #0000ff;">this</span>, <span style="color: #0000ff;">params</span><span style="color: #000000;">);
} options </span>= options ||<span style="color: #000000;"> {};
</span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">this</span><span style="color: #000000;">.each(function () {
</span><span style="color: #0000ff;">var</span> opt = $.data(<span style="color: #0000ff;">this</span>, <span style="color: #800000;">"</span><span style="color: #800000;">tips</span><span style="color: #800000;">"</span><span style="color: #000000;">);
</span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (opt) {
$.extend(opt.options, options);
} </span><span style="color: #0000ff;">else</span><span style="color: #000000;"> {
$.data(</span><span style="color: #0000ff;">this</span>, <span style="color: #800000;">"</span><span style="color: #800000;">tips</span><span style="color: #800000;">"</span><span style="color: #000000;">, {
options: $.extend({}, $.fn.tips.defaults, options)
});
init(</span><span style="color: #0000ff;">this</span><span style="color: #000000;">);
}
});
}; $.fn.tips.defaults </span>=<span style="color: #000000;"> {
cls: </span><span style="color: #800000;">""</span><span style="color: #000000;">,
content: </span><span style="color: #0000ff;">null</span><span style="color: #000000;">,
wrapColor: </span><span style="color: #800000;">"</span><span style="color: #800000;">blue</span><span style="color: #800000;">"</span><span style="color: #000000;">
}; </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> ($.parser) {
$.parser.plugins.push(</span><span style="color: #800000;">'</span><span style="color: #800000;">tips</span><span style="color: #800000;">'</span><span style="color: #000000;">)
}
})(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 () {
</span><span style="color: #0000ff;">var</span> tableTd = $(<span style="color: #800000;">'</span><span style="color: #800000;">div.datagrid-body td[field="productname"]</span><span style="color: #800000;">'</span>); <span style="color: #008000;">//</span><span style="color: #008000;"><span style="color: #800000;">productname</span>是列名</span>
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插件
</div>
<div class="postDesc">posted @ <span id="post-date">2015-11-19 09:45</span> <a href="http://www.cnblogs.com/xuguanghui/">直钩钓鱼</a> 阅读(<span id="post_view_count">5703</span>) 评论(<span id="post_comment_count">0</span>) <a href="https://i.cnblogs.com/EditPosts.aspx?postid=4976636" rel="nofollow">编辑</a> <a href="#" onclick="AddToWz(4976636);return false;">收藏</a></div>
</div>
<script type="text/javascript">var allowComments=true,cb_blogId=167430,cb_entryId=4976636,cb_blogApp=currentBlogApp,cb_blogUserGuid='2c86fefc-4041-e311-8d02-90b11c0b17d6',cb_entryCreatedDate='2015/11/19 9:45:00';loadViewCount(cb_entryId);</script>
EasyUI Datagrid 鼠标悬停显示单元格内容 复制代码的更多相关文章
- EasyUI Datagrid 鼠标悬停显示单元格内容
第一种方式: .js 定义函数 <script type="text/javascript"> //格式化单元格提示信息 function formatCellTool ...
- EasyUI的Datagrid鼠标悬停显示单元格内容
功能描述:table鼠标悬停显示单元格内容 1.js函数 function hoveringShow(value) { return "<span title='" + va ...
- easyUi datagrid鼠标经过提示单元格内容
此文章是基于 EasyUI+Knockout实现经典表单的查看.编辑 一. jquery.cellTip.js /** * 扩展两个方法 */ using('datagrid', function() ...
- EXTJS 4.2 实现 gridpanel 鼠标悬停单元格以提示信息的方式显示单元格内容。
由于gridpanel的单元格里的文字太多时候,都由省略号代替,就想实现如题的功能,经过反复实验,终于搞定了!直接上代码: me.on('itemmouseenter', function (view ...
- qtableview 鼠标划过单元格弹出标签显示单元格内容
QStandardItem *item = new QStandardItem(show_content); infoTableModel->setItem(1, 1, item); item- ...
- WinForm中DataGridView复制选中单元格内容解决方案
WinForm中DataGridView鼠标选中单元格内容复制方案 1.CTR+C快捷键复制 前提:该控件ClipboardCopyMode属性设置值非Disable: 2.鼠标框选,自定义代码实现复 ...
- EasyUI datagrid单元格文本超出显示省略号,鼠标移动到单元格显示文本
nowrap : true; 是前提 $('#×××').datagrid({ nowrap : true,//设置为true,当数据长度超出列宽时将会自动截取 }); 省略号样式: <sty ...
- C# DataGridView在单元格提示里(ToolTip)显示完整的单元格内容
当单元格内容太多时,则会忽略后面的内容 解决方案: 添加Dgv鼠标移到单元格事件时,设置当前单元格的ToolTipText属性内容为当前单元格内容 void From_Load(object send ...
- 获取wpf datagrid当前被编辑单元格的内容
原文 获取wpf datagrid当前被编辑单元格的内容 确认修改单元个的值, 使用到datagrid的两个事件 开始编辑事件 BeginningEdit="dataGrid_Beginni ...
随机推荐
- js几秒以后倒计时跳转示例
代码如下: <html> <head> <title>出错啦~~~</title> <link href="css/login1.css ...
- 【Unity与23种设计模式】状态模式(State)
定义: "让一个对象的行为随着内部状态的改变而变化,而该对象也像是换了类一样" 应用场景: 角色AI:控制角色在不同状态下的AI行为 服务器连接状态:开始连线.连线中.断线等状态 ...
- vue路由跳转时判断用户是否登录功能
通过判断该用户是否登录过,如果没有登录则跳转到login登录路由,如果登录则正常跳转. 一丶首先在用户登录前后分别给出一个状态来标识此用户是否登录(建议用vuex): 简单用vuex表示一下,不会可以 ...
- Java之面向对象例子(一)
定义一个人类,给这个类定义一个从身份证获取生日的方法,输入身份证,获取出生年月日 //主方法 package com.hanqi.maya.model; import java.util.Scanne ...
- css动画属性--小球移动
主体只有一个div <body> <div></div> </body> 样式部分(测试:目前的浏览器还是需要加前缀才能兼容) <style> ...
- ConcurrentLinkedQueue 源码 since java1.5
1 父类 java.lang.Object 继承者 java.util.AbstractCollection<E> 继承者 java.util.AbstractQueue<E> ...
- C/C++中static关键字的用法
1.什么是static? static 是C/C++中很常用的修饰符,它被用来控制变量的存储方式和可见性. 1.1static的引入 我们知道在函数内部定义的变量,当程序执行到它的定义处时,编译器为它 ...
- 苹果APP发布
1 发布方式 苹果发布上架有两种方式,一种是上传到苹果商店,一种是挂在web服务器上扫描下载,下面分别介绍这两种发布方式 1.1 上传AppStore 1. 用公司账号或者个人开发账号生成上架.p12 ...
- Hybris安装和各个Extention简单介绍
前言:突然想好好梳理一下这几个月所学的内容了,顺便让自己的知识有一个系统的框架. 一. 安装JDK 请安装最新的Oracle JDK 8.0版(从Oracle官网下载). 二.开发工具建议使用 In ...
- 【CSS】background 的覆盖
1. 样式覆盖问题描述 现象:class1 为dom节点默认样式,class2为dom节点后增加样式,发现class2的background 被class1的覆盖 解决办法:在class2 的back ...