easyUi datagrid鼠标经过提示单元格内容
此文章是基于 EasyUI+Knockout实现经典表单的查看、编辑
一. jquery.cellTip.js
/**
* 扩展两个方法
*/
using('datagrid', function(){
$.extend($.fn.datagrid.methods, {
/**
* 开打提示功能
* @param {} jq
* @param {} params 提示消息框的样式
* @return {}
*/
doCellTip: function(jq, params){
function showTip(data, td, e){
if ($(td).text() == "")
return;
data.tooltip.text($(td).text()).css({
top: (e.pageY + 10) + 'px',
left: (e.pageX + 20) + 'px',
'z-index': $.fn.window.defaults.zIndex,
display: 'block'
});
};
return jq.each(function(){
var grid = $(this);
var options = $(this).data('datagrid');
if (!options.tooltip) {
var panel = grid.datagrid('getPanel').panel('panel');
var defaultCls = {
'border': '1px solid #333',
'padding': '2px',
'color': '#333',
'background': '#f7f5d1',
'position': 'absolute',
'max-width': '200px',
'border-radius' : '4px',
'-moz-border-radius' : '4px',
'-webkit-border-radius' : '4px',
'display': 'none'
}
var tooltip = $("<div id='celltip'></div>").appendTo('body');
tooltip.css($.extend({}, defaultCls, params.cls));
options.tooltip = tooltip;
panel.find('.datagrid-body').each(function(){
var delegateEle = $(this).find('> div.datagrid-body-inner').length ? $(this).find('> div.datagrid-body-inner')[0] : this;
$(delegateEle).find('td').each(function(i){
var ele = $(this).parent();
// 适用于treegrid
if($(this).find('td').length > 0)
ele = $(this);
$(ele).undelegate('td', 'mouseover').undelegate('td', 'mouseout').undelegate('td', 'mousemove').delegate('td', {
'mouseover': function(e){
if (params.delay) {
if (options.tipDelayTime)
clearTimeout(options.tipDelayTime);
var that = this;
options.tipDelayTime = setTimeout(function(){
showTip(options, that, e);
}, params.delay);
}
else {
showTip(options, this, e);
} },
'mouseout': function(e){
if (options.tipDelayTime)
clearTimeout(options.tipDelayTime);
options.tooltip.css({
'display': 'none'
});
},
'mousemove': function(e){
var that = this;
if (options.tipDelayTime)
clearTimeout(options.tipDelayTime);
//showTip(options, this, e);
options.tipDelayTime = setTimeout(function(){
showTip(options, that, e);
}, params.delay);
}
});
}); }); } });
},
/**
* 关闭消息提示功能
*
* @param {}
* jq
* @return {}
*/
cancelCellTip: function(jq){
return jq.each(function(){
var data = $(this).data('datagrid');
if (data.tooltip) {
data.tooltip.remove();
data.tooltip = null;
var panel = $(this).datagrid('getPanel').panel('panel');
panel.find('.datagrid-body').undelegate('td', 'mouseover').undelegate('td', 'mouseout').undelegate('td', 'mousemove')
}
if (data.tipDelayTime) {
clearTimeout(data.tipDelayTime);
data.tipDelayTime = null;
}
});
}
});
});
二. 测试页面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>datagrid鼠标经过提示单元格内容</title>
<%@ include file="/common/head.jsp"%>
</head>
<body>
<div style="margin:10px 0;">
<a href="#" onclick="doCellTip()">显示提示消息</a>
<a href="#" onclick="cancelCellTip()">禁止消息显示</a>
<div id="info"></div>
</div> <table id="test" class="easyui-datagrid" style="width:100%;height:520px;" data-options="fitColumns:true, singleSelect:true, rownumbers:true">
<thead>
<tr>
<th data-options="field:'direction', width:150, align:'center'">direction</th>
</tr>
</thead>
</table> <%@ include file="/common/foot.jsp"%>
<script type="text/javascript" src="content/js/jquery-plugin/cellTip/jquery.cellTip.js"></script>
<script type="text/javascript">
function doCellTip(){
$('#test').datagrid('doCellTip', {'cls':{'max-width':'200px'}});
}
function cancelCellTip(){
$('#test').datagrid('cancelCellTip');
} $(function(){
var data = ${data};
ko.bindingViewModel(new viewModel(data));
});
using(['messager', 'datagrid'], function(){
$('#test').datagrid({
onLoadSuccess: function(data){
$(this).datagrid('doCellTip', {'cls':{'max-width':'600px'}, 'delay':500});
}
});
});
</script>
</body>
</html>
testGrid.jsp
easyUi datagrid鼠标经过提示单元格内容的更多相关文章
- EasyUI Datagrid 鼠标悬停显示单元格内容 复制代码
EasyUI Datagrid 鼠标悬停显示单元格内容 ,halign:, align: 0 « 上一篇:LINQ to Entities 中的查询» 下一篇:去掉字符串中的非数字字符 posted ...
- EasyUI Datagrid 鼠标悬停显示单元格内容
第一种方式: .js 定义函数 <script type="text/javascript"> //格式化单元格提示信息 function formatCellTool ...
- EasyUI的Datagrid鼠标悬停显示单元格内容
功能描述:table鼠标悬停显示单元格内容 1.js函数 function hoveringShow(value) { return "<span title='" + va ...
- VC/MFC 在ListCtl 控件中随鼠标移动提示单元格信息
BEGIN_MESSAGE_MAP(CTipListCtrl, CListCtrl) //{{AFX_MSG_MAP(CTipListCtrl) ON_WM_MOUSEMOVE() ON_WM_DES ...
- EasyUI datagrid单元格文本超出显示省略号,鼠标移动到单元格显示文本
nowrap : true; 是前提 $('#×××').datagrid({ nowrap : true,//设置为true,当数据长度超出列宽时将会自动截取 }); 省略号样式: <sty ...
- 获取wpf datagrid当前被编辑单元格的内容
原文 获取wpf datagrid当前被编辑单元格的内容 确认修改单元个的值, 使用到datagrid的两个事件 开始编辑事件 BeginningEdit="dataGrid_Beginni ...
- C# DataGridView在单元格提示里(ToolTip)显示完整的单元格内容
当单元格内容太多时,则会忽略后面的内容 解决方案: 添加Dgv鼠标移到单元格事件时,设置当前单元格的ToolTipText属性内容为当前单元格内容 void From_Load(object send ...
- EXCEL中统计单元格内容出现次数
参考网站: https://jingyan.baidu.com/article/7c6fb428dfcc9580642c90ae.html 统计单元格内容出现次数是工作中经常会涉及到的问题. 那么,如 ...
- 原创:用VBA实现将鼠标选择的单元格按照指定格式合并并复制到剪切板
原创:用VBA实现将鼠标选择的单元格按照指定格式合并并复制到剪切板 一.主要实现以下功能:1.用鼠标选择单元格(可谓连续单元格,也可为不连续的)后,按照要求格式“证件号码:+选定内容+“,”+”选定内 ...
随机推荐
- Day 1. 占位符的使用方法(%d,%s)(格式化输出)
方法1 name = input("请输入名字1") age = input ("请输入年龄") hobby = input("请输入兴趣爱好&qu ...
- docker和定时任务
查看linux信息 cat /etc/issue 以id运行容器docker start 1c3339d7f9a8通过id结束容器 docker kill 1c3339d7f9a8 Ubuntu 安装 ...
- elasticsearch Geo Distance Query
Geo Distance Query 过滤器文档只包括在一个特定距离内存在于一个地理点上的命中.假设下列映射和索引文档: PUT /my_locations { "mappings" ...
- [小tips]使用vscode,根据vue模板文件生成代码
本着苍蝇虽小也是肉的精神...... 目标: 我们希望每次新建.vue文件后,VSCODE能够根据配置,自动生成我们想要的内容. 方法: 打开VSCODE编辑器,依次选择"文件 -> ...
- MVC Filter中加入验证并跳转
public class BuildingFilter : ActionFilterAttribute { /// <summary> /// 验证 Building Cookie add ...
- Cygwin安装配置
1.下载安装Cygwin 我们可以到Cygwin的官方网站下载Cygwin的安装程序,地址是: http://www.cygwin.com/ 或者直接使用下载连接来下载安装程序,下载连接是: ht ...
- Linux 线程占用CPU过高定位分析
今天朋友问我一个Linux程序CPU占用涨停了,该如何分析, CPU占用过高,模拟CPU占用过高的情况 先上一段代码: #include <iostream> #include <t ...
- a标签发送邮件
<a href="Mailto:292808135@qq.com?CC=292808135@qq.com&Subject=反馈&Body=花式求喷~%0A您的不满就是我 ...
- antlr提取代码注释
1. 来由 为什么要写提取注释呢,起因是工作需要.弄这么个不太重要的功能点来讲,旨在抛砖引玉. 一般而言,大家使用antlr解析源代码的时候,不会关心注释和空格之类内容,默认会过滤掉,不会放到语法树里 ...
- ROR中h()方法和sanitize的区别及Html Filter
一般来说,通常使用input的field都会做一些filter的动作,避免被不怀好意之徒塞一些危险的HTML code(script等)进去搞破坏.在ROR中,我们在前面加一个h()(一般不用括号?不 ...