Spreadjs9怎样下拉帮助和悬浮提示一起显示?

Spreadjs9使我们经常用到的一种表格插件,而当前插件没有现成的悬浮的属性,网上也有很多扩充悬浮属性的方法,但相关方法经常会有一些性能问题(因悬浮方法是单独设置)以及和原有属性冲突的情况,如下代码段可解决这个问题
1.首先重新定义悬浮的特性
想要悬浮和哪一种单元格属性共存则重写那种属性 TextCellType
`function TextCellType() {
//基础按钮 方法重置
GcSpread.Sheets.TextCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
return {
x: window.event.clientX,//x//对于 行列位置处理
y: window.event.clientY,//y
row: context.row,
col: context.col,
cellStyle: cellStyle,
cellRect: cellRect,
sheetArea: context.sheetArea
};
};

GcSpread.Sheets.TextCellType.prototype.processMouseEnter = function (hitinfo) {
        var ActiveSheet = BBGridSpread.getActiveSheet();
        if (this._toolTipElement) {
            try {
                document.body.removeChild(this._toolTipElement);
            }
            catch (e) { }
            this._toolTipElement = null;
        }
        if ($("#TipID")[0] != undefined) {
            try {
                document.body.removeChild($("#TipID")[0]);
            } catch (e) {
            }
            this._toolTipElement = null;
        }
        
        var tips = "提示信息6666";
        if (tips == undefined || tips == "") {
            return;
        }
        if (!this._toolTipElement) {
            var div = document.createElement("div");
            div.id = "TipID";
            $(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).html(tips)
        .css("top", hitinfo.y)
        .css("left", hitinfo.x);
        $(this._toolTipElement).hide();
        document.body.insertBefore(this._toolTipElement, null);
        $(this._toolTipElement).show("fast");
    };


GcSpread.Sheets.TextCellType.prototype.processMouseLeave = function (hitinfo) {
        if (this._toolTipElement) {
            try {
                document.body.removeChild(this._toolTipElement);
            } catch (e) {
            }
            this._toolTipElement = null;
        }
        if ($("#TipID")[0] != undefined) {
            try {
                document.body.removeChild($("#TipID")[0]);
            } catch (e) {
            }
            this._toolTipElement = null;
        }
    };

}`

2.解决性能问题
如上重新定义后,即可批量设置悬浮属性

function Tips() {
    var ActiveSheet;//当前活动sheet页
    var JSON = ActiveSheet.toJSON();//转换为对象
    var ATips = {};//此处准备相关的需要浮动显示的坐标
    ATips["1_2"] = "22222";
    ATips["2_2"] = "22222";
    ATips["3_2"] = "22222";

    //TextCellType 绑定划入划出方法
    TextCellType();

    //给单元格增加相关信息
    for (var i = 0; i < JSON.rowCount; i++) {
        for (var j = 0; j < JSON.columnCount; j++) {
            if (ATips[i + "_" + j] != undefined) {
                JSON.data.dataTable[i][j].style.cellType = new GcSpread.Sheets.TextCellType();
            }
        }
    }
    ActiveSheet.fromJSON(JSON);
}

批量执行,提高性能
同时解决下拉共存和性能问题

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值