调用:
$('#dg').datagrid('doCellTip', { 'max-width': '100px' });

/**
* 扩展两个方法
*/
$.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).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;
}
});
}
});

最新文章

  1. JAVA NIO FileChannel 内存映射文件
  2. centos 查看脚本
  3. [Math] Backpropagation
  4. Apache服务器httpd.exe进程占用cpu超过50%的解决方法
  5. Smarty s01
  6. 微软发布了ASP.NET WebHooks预览版
  7. poj 3694 Network
  8. addChildViewController 用法
  9. myeclipse 配置weblogic 异常
  10. [渣译文] SignalR 2.0 系列:SignalR的高频实时通讯
  11. 通过Jasmine和Guard自动测试JavaScript
  12. 玩转spring boot——websocket
  13. python基础===八大排序算法的 Python 实现
  14. 基于Elasticsearch搜索平台设计
  15. BZOJ4319 cerc2008 Suffix reconstruction 字符串 SA
  16. 内存地址 id
  17. linux c++ curl https 请求并双向验证SSL证书
  18. uva-10720-贪心
  19. 配置 cxf-ws spring bean 文件
  20. hdu 1847 博弈基础题 SG函数 或者规律2种方法

热门文章

  1. 编写nios-shell时想到的问题-回车vs换行
  2. PHP如何安装和配置Zend Studio
  3. poj 3237(树链剖分+线段树)
  4. ThinkPad如何修改fn键默认操作
  5. sublime text 全局搜索快捷键
  6. Decorator [ˈdekəreɪtə(r)] 修饰器/装饰器 -- 装饰模式
  7. oracle 存储过程 示例
  8. BOM*创建工艺路线
  9. 数据库选型之MySQL(固态硬盘)
  10. Android传感器开发