2022-04-19 帆软 鼠标移入表格显示颜色代码

本文介绍如何在帆软报表中实现在鼠标移入表格时显示颜色的效果。通过绑定body的初始化后JS事件,调整字体大小、行高和加粗字体。当筛选条件变化导致效果失效时,需要在条件控件的编辑结束事件中重新应用代码。注意,参数面板的筛选条件变化不会触发此效果,因为会重新渲染body。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

绑在body的初始化后js事件上。

setTimeout(function() {
        //选择时背景颜色变量  
        var oldColor = "rgb(255, 255, 255)";
        var newColor = "rgb(230, 247, 255)";

        $('.x-table td').hover(function() {
                if ($(this).attr("style").indexOf("background-color") == -1) {
                        $(this).css('background', newColor).siblings().css("background", newColor);
                }
        }, function() {
                if ($(this).attr("style").indexOf("background-color") == -1) {
                        $(this).css('background', oldColor).siblings().css("background", oldColor);
                }
        });
}, 1000);

改变字体大小,行高

setTimeout(function() {
        //选择时背景颜色变量  
        var oldColor = "rgb(255, 255, 255)";
        var newColor = "rgb(230, 247, 255)";

        $('.x-table td').hover(function() {
                if ($(this).attr("style").indexOf("background-color") == -1) {
                        $(this).css('background', newColor).siblings().css("background", newColor);
                        $(this).css("font-size", 16).siblings().css("font-size", 16);
                        $(this).css("height", 28).siblings().css("height", 28);
                }
        }, function() {
                if ($(this).attr("style").indexOf("background-color") == -1) {
                        $(this).css('background', oldColor).siblings().css("background", oldColor);
                        $(this).css("font-size", 12).siblings().css("font-size", 12);
                        $(this).css("height", 20).siblings().css("height", 20);
                        
                }
        });
}, 1000);

加粗字体

setTimeout(function() {
        //选择时背景颜色变量  
        var oldColor = "rgb(255, 255, 255)";
        var newColor = "rgb(200, 204, 255)";

        $('.x-table td').hover(function() {
                if ($(this).attr("style").indexOf("background-color") == -1) {
                        $(this).css('background', newColor).siblings().css("background", newColor);
                        $(this).css("font-weight", 700).siblings().css("font-weight", 700);

                }
        }, function() {
                if ($(this).attr("style").indexOf("background-color") == -1) {
                        $(this).css('background', oldColor).siblings().css("background", oldColor);
                        $(this).css("font-weight", 400).siblings().css("font-weight", 400);     
                }
        });
}, 1000);

改变筛选条件以后如果这个效果失效了,需要在改变条件的控件加编辑结束事件粘贴进效果代码。参数面板的筛选条件不用,改变参数面板会重新渲染body

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值