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 ...
随机推荐
- [Hadoop源码系列] FairScheduler分配申请和分配container的过程
1.如何申请资源 1.1 如何启动AM并申请资源 1.1.1 如何启动AM val yarnClient = YarnClient.createYarnClient setupCredentials( ...
- iOS内购(IAP)中的那些坑
公司的公共库原来并没有这部分的代码,以前做内购是用两个比较有名的github上的第三方库.一个叫MKStoreKit,另一个叫IAPManager,我看了一下写的都很辣鸡,使用起来很不方便,而且写的还 ...
- 关于tomcat下startup.bat双击闪退的问题
背景:之前做单点登录,复制了几个tomcat,改了各自端口,当做不同服务器用. 今天无意间随便点击了一个tomcat下的startup.bat批处理文件,结果出来控制台,没出几行信息就闪退了.点击其他 ...
- [补] winpcap编程——EAPSOCKET实现校园网锐捷登录(mentohust)
EAP SOCKET Implement Mentohust 时间20161115 对于EAP协议不了解,可参考上一篇随笔. 通过抓包分析校园网的锐捷登录流程,我在上一篇随笔中实现了EAPSOCKET ...
- 学习笔记TF031:实现VGGNet
VGGNet,牛津大学计算机视觉组(Visual Geometry Group)和Google DeepMind公司一起研发,深度卷积神经网络.VGGNet反复堆叠3x3小型卷积核和2x2最大池化层, ...
- AugularJS从入门到实践(三)
前 言 前端 AngularJS是为了克服HTML在构建应用上的不足而设计的.(引用百度百科) AngularJS使用了不同的方法,它尝试去补足HTML本身在构建应用方面的缺陷.Angu ...
- Java利用内存映射文件实现按行读取文件
我们知道内存映射文件读取是各种读取方式中速度最快的,但是内存映射文件读取的API里没有提供按行读取的方法,需要自己实现.下面就是我利用内存映射文件实现按行读取文件的方法,如有错误之处请指出,或者有更好 ...
- teamviewer试用期到期解决
1.命令行输入:%appdata%删除teamviewer文件夹2.命令行输入:regedit删除teamviewer文件夹3.卸载tv4.控制面板->设备管理器->网络适配器->f ...
- [补档]vijos1883 月光的魔法
vijos1883 月光的魔法 题目 传送门:https://www.vijos.org/p/1883 背景 影几欺哄了众生了 天以外-- 月儿何曾圆缺 描述 有些东西就如同月光的魔法一般. Lu ...
- 31. leetcode 122. Best Time to Buy and Sell Stock II
122. Best Time to Buy and Sell Stock II Say you have an array for which the ith element is the price ...