JS Customize the Style of Cell Prompt Text

  • Last update:December 28, 2020
  • I. Overview

    1.1 Problem Description

    How to customize the styles of cell tooltip as shown below?

    3.gif

           

    1.2 Solution

    The cell tooltip is realized by using the title attribute in HTML. We can set a custom style through JavaScript and CSS.

    II. Example

    2.1 Design Report

    1) Create a new report and design the report body as follows:

    image.png

    2) Click A1, select Cell Attributes > Other > Tooltip of cell, and input formula: =$$$.

    image (1).png


    2.2 Add event

    Select Template > Web Attributes, select Pagination Preview, and add a Loading End event.

     image (2).png

    The JS code is:

    var oldTitle = null;
    $('td').bind('mouseover mouseout mousemove', function(event) {
    var left = event.pageX;
    var top = event.pageY;
    var ele = event.target;
    var title = ele.title;
    var type = event.originalEvent.type;
    if (type == 'mouseover') {
    oldTitle = title;
    ele.title = '';
    console.log(title);
    if (title.length != 0) {
    var showEle = $('<div></div>', {
    text: title,
    class: 'showTitleBox'
    }).css({
    position: 'absolute',
    top: top + 10,
    left: left,
    border: '1px solid #00cccc', //border
    borderRadius: '5px', //rounded corner
    background: "#00cccc", //background color
    fontFamily: 'SimHei', //font
    fontSize: '15px' // font size
    })
    showEle.appendTo('body');
    }
    } else if (type == 'mouseout') {
    ele.title = oldTitle;
    $('.showTitleBox').remove();
    } else if (type == 'mousemove') {
    $('.showTitleBox').css({
    top: top + 10,
    left: left
    })
    }
    })

    Tips:CSS properties can be modified according to the requirements.


    2.3 View results

    Save the report, select Pagination Preview, and the results are as shown below:

    image (3).png

    Tips:Not support mobile devices.

    III. Completed Template

    Attachment List


    Theme: Report Application
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy