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.用鼠标选择单元格(可谓连续单元格,也可为不连续的)后,按照要求格式“证件号码:+选定内容+“,”+”选定内 ...
随机推荐
- PHP7 - 如何禁用Xdebug
操作系统:Cent OS 7 什么是Xdebug?看它的官方网站介绍: https://xdebug.org/index.php 为什么要禁用呢?这是因为Composer,这两种工具有冲突,在使用Co ...
- 978. Longest Turbulent Subarray
A subarray A[i], A[i+1], ..., A[j] of A is said to be turbulent if and only if: For i <= k < j ...
- 内核漏洞学习—熟悉HEVD
一直以来内核漏洞安全给很多人的印象就是:难,枯燥.但是内核安全是否掌握是衡量一个系统安全工程师水平的标准之一,也是安全从业人员都应该掌握的基本功.本文通过详细的实例带领读者走进内核安全的大门.难度系数 ...
- 使用Dockerfile定制镜像
Dockerfile是一个文本文件,其中包含额一条一条的指令,每一条指令构建一层,因此每一条指令的作用就是描述这一层应当如何的构建. 以构建nginx镜像为例,使用Dockerfile构建的步骤如下: ...
- Netty核心概念(8)之Netty线程模型
1.前言 第7节初步学习了一下Java原本的线程池是如何工作的,以及Future的为什么能够达到其效果,这些知识对于理解本章有很大的帮助,不了解的可以先看上一节. Netty为什么会高效?回答就是良好 ...
- Java之集合(二十)LinkedBlockingQueue
转载请注明源出处:http://www.cnblogs.com/lighten/p/7503678.html 1.前言 本章介绍阻塞队列LinkedBlockingQueue,这是一个基于链表的可选长 ...
- 【树】Sum Root to Leaf Numbers
题目: Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a nu ...
- win10下用Linux搭建python&nodejs开发环境
Win10下用自带Linux系统搭建开发环境 Win10下用自带Linux系统搭建开发环境启用Linux老版本(win10 1709之前):新版本(win10 1709之后)卸载linux老版本新版本 ...
- Centos调整时间时区
一台VPS的时间出错,使用常规手段修改均失败.提示hwclock failed : ntpdate stdtime.sinica.edu.tw 如果你的 VPS 提示没有 ntpdate 这个命令,可 ...
- 09 - JavaSE之线程
线程 线程的基本概念 线程是一个程序里面不同的执行路径. 进程与线程的区别 每个进程都有独立的代码和数据空间(进程上下文),进程间的切换开销大. 线程可以看作轻量级的进程,同一类线程共享代码和数据空间 ...