SpreadJS自定义单元格系列-Tip单元格

SpreadJS Tip单元格,当鼠标移动到单元格,显示出一个小提示。

发布于 2016/07/28 00:00

SpreadJS Tip单元格,当鼠标移动到单元格,显示出一个小提示。

image

要实现鼠标移动到单元格上时显示出提示看,只需要重写TextCellType的processMouseEnter方法,在方法中创建一个Tip即可。同时在processMouseLeave方法中销毁Tip。

function TipCellType() {
    
}
TipCellType.prototype = new GcSpread.Sheets.TextCellType();
TipCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
    return {
        x: x,
        y: y,
        row: context.row,
        col: context.col,
        cellStyle: cellStyle,
        cellRect: cellRect,
        sheetArea: context.sheetArea
    };
}
TipCellType.prototype.processMouseEnter = function (hitinfo) {
    if (!this._toolTipElement) {
        var div = document.createElement("div");
        $(div).css("position", "absolute")
        .css("border", "1px #C0C0C0 solid")
        .css("box-shadow", "1px 2px 5px rgba(0,0,0,0.4)")
        .css("font", "9pt Arial")
        .css("background", "white")
        .css("padding", 5);
        
        this._toolTipElement = div;
    }
    $(this._toolTipElement).text("Cell [R:" + hitinfo.row + "] : [C:" + hitinfo.col + "]")
    .css("top", hitinfo.y + 15)
    .css("left", hitinfo.x + 15);
    $(this._toolTipElement).hide();
    document.body.insertBefore(this._toolTipElement, null);
    $(this._toolTipElement).show("fast");
};
TipCellType.prototype.processMouseLeave = function (hitinfo) {
    if (this._toolTipElement) {
        document.body.removeChild(this._toolTipElement);
        this._toolTipElement = null;
    }
};

 

RunJS演示地址:http://runjs.cn/detail/uzfkszof

 

更多资源

SpreadJS中文学习指南:http://demo.grapecity.com.cn/SpreadJS/TutorialSample/#/samples

SpreadJS在线英文产品文档:http://sphelp.grapecity.com/webhelp/SpreadJSWeb/webframe.html#welcome.html

如果您对SpreadJS产品感兴趣,可以到官方网站下载试用:/developer/spreadjs

如果你有疑问,可以到GCDN论坛获得技术支持:http://gcdn.grapecity.com.cn

关于葡萄城

葡萄城是专业的软件开发技术和低代码平台提供商,以“赋能开发者”为使命,致力于通过表格控件、低代码和BI等各类软件开发工具和服务,一站式满足开发者需求,帮助企业提升开发效率并创新开发模式。葡萄城开发技术始于1980年,40余年来始终聚焦软件开发技术,有深厚的技术积累和丰富的产品线。是业界能够同时赋能软件开发和低代码开发的企业。凭借过硬的产品能力、活跃的开发者社区和丰富的伙伴生态,与超过3000家合作伙伴紧密合作,产品广泛应用于信息和软件服务、制造、交通运输、建筑、金融、能源、教育、公共管理等支柱产业。

推荐相关案例
推荐相关资源
关注微信
葡萄城社区二维码

关注“葡萄城社区”

加微信获取技术资讯

加微信获取技术资讯

想了解更多信息,请联系我们, 随时掌握技术资源和产品动态