zoukankan      html  css  js  c++  java
  • datagrid鼠标悬浮提示

    /**
    * 扩展两个方法
    */
    $.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' : '1px',
    '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);
    options.tipDelayTime = setTimeout(
    function() {
    showTip(options, that, e);
    }, params.delay);
    } else {
    showTip(options, that, e);
    }
    }
    });
    });

    }

    });
    },
    /**
    * 关闭消息提示功能
    * @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;
    }
    });
    }
    });

    function doCellTip(){
    $('#mainGrid').datagrid('doCellTip',{'max-width':'100px'});
    }
    function cancelCellTip(){
    $('#mainGrid').datagrid('cancelCellTip');
    }


    function doCellTip(){
    $('#mainGrid').datagrid('doCellTip',{'max-width':'100px'});
    }
    function cancelCellTip(){
    $('#mainGrid').datagrid('cancelCellTip');
    }

  • 相关阅读:
    公布一些常用的WebServices
    ARM的嵌入式Linux应用程序开发研究
    c++读写剪贴板代码
    如何破解路由器密码(CISCO)!
    用Shell扩展实现源代码统计程序(转)
    图文例解C++类的多重继承与虚拟继承
    MSDN上关于ADO示例代码
    不错的句子
    codeforces #271(div2) F. Ant colony
    [Z]CUDA中Bank conflict冲突
  • 原文地址:https://www.cnblogs.com/huangf714/p/5872090.html
Copyright © 2011-2022 走看看