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 = (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 鼠标悬停显示单元格内容的更多相关文章
- EasyUI Datagrid 鼠标悬停显示单元格内容 复制代码
EasyUI Datagrid 鼠标悬停显示单元格内容 ,halign:, align: 0 « 上一篇:LINQ to Entities 中的查询» 下一篇:去掉字符串中的非数字字符 posted ...
- 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- ...
- 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 ...
- LaTex: 表格单元格内容 分行显示/换行
问题:如何同时让表格同一行一个单元格的文字能垂直居中?比如说文字超长超出页面范围需要分行显示 答:(来源于smth) 方案一: \newcommand{\tabincell}[2]{\begin{ta ...
随机推荐
- 18-EasyNetQ:发生错误的情况
这一篇文章让我们看看在消息系统中可能发生的各种错误的情况下,看下EasyNetQ如何处理它们. 订阅服务挂了 当你写了一个windows 服务,用来订阅一个NewCustomerMessage消息. ...
- 代码托管SVN到Git迁移(使用小乌龟工具)
1.环境信息 Git Server 华为软件开发云 代码托管 SVN Server 本地SVN服务器 Windows Server2012 R2 本地主机 Win ...
- 智联招聘 卓聘IM演进过程
1. 卓聘IM开发背景 智联卓聘是智联旗下高端人才招聘平台,成立快4年了,业务增涨每年以100%速度增涨,业务增涨快在开发和上线速度要求也比较高. 2016年6月提出IM开发需求,7月初上线,开发人 ...
- LoadRunner压力测试之Unique Number参数类型、Random Number参数类型浅析
前几天工作需要用LoadRunner进行压力测试,期间对手机号进行参数化设置. 当时选用了<Value>137{Random_quhao}{Unique_weiyi}</Value& ...
- Android Bitmap 常见的几个操作:缩放,裁剪,旋转,偏移
Android Bitmap 相关操作 常见的几个操作:缩放,裁剪,旋转,偏移 很多操作需要 Matrix 来支持:Matrix 通过矩阵来处理位图,计算出各个像素点的位置,从而把bitma ...
- AddDigitsTotal - 把数字中单个数相加
给定一个int数字,把数字中的单个数相加起来:得到的结果如果不是个位数,继续相加 如给定 19,执行1+9 = 10 --> 1 + 0 = 1 返回1 给定22,返回4 思路很简单,把各个位 ...
- Python基础之常用模块(二)
一.sys模块 1.sys.exit() 退出程序,这是正常退出程序,与之前用的break不同的是,break只是退出循环,循环之后的代码还会正常运行 2.sys.argv 会返回一个列表,列表中的 ...
- ABP从入门到精通(1):aspnet-zero-core项目启动及各项目源码说明
一.ABP的简单介绍 ABP是"ASP.NET Boilerplate Project (ASP.NET样板项目)"的简称. ASP.NET Boilerplate是一个用最佳实践 ...
- github 发布项目
自己开发了一个插件或项目,需要发布到github上,之前看到很多文章,但是都会有一些问题,经过自己多次尝试,想分享给初学者们. 首先你需要一个github账号,所有还没有的话先去注册吧! 官网:htt ...
- JavaSE(七)之内部类
上一篇我们学习了接口还有访问控制,在以后的工作中接口是我们经常要碰到的,所以一定要多去回顾.接下来介绍一下内部类.很多时候我们创建类的对象的时候并不需要使用很多次,每次只使用一次 这个时候我们就可以使 ...