JS Mouse Over Cell(Row) Style Change

  • Last update:  2020-12-15
  • I. Overview

    1.1 Requirement

    In making a report, in order to highlight the cell the mouse moves over, we usually use JavaScript to change the background color and font size of the cell on mousehover or mousedown and go back to previous background color and font size on mouseout.

    As shown in the figure below, when the mouse moves over the cell, the background color of the cell becomes red and the font size is enlarged. When the mouse is down, the background color of the cell returns to white.

    Change the background color and font size of the row on mousehover and mousedown, as shown below:


    1.2 Solution

    Identify the cell or the row the mouse moves over and then change the background color and font size.

    You will learn
    • Sample

      • Sample 1: Restyle the cell the mouse moves over

      • Sample 2: Restyle the row the mouse moves over

    • Download the templates

    II. Sample

    2.1 Sample 1: Restyle the cell the mouse moves over

    1) Design the template as follows:

    2) Click [Template]-[Web Attributes]-[Data Entry Preview], uncheck [Individually set for the template], and add a Load End event:

      

    Input the following JavaScript codes:

    // on mousemove
    $(".x-table td").mousemove(function() {
    // background color: red
            $(this).css("background-color","red");
    // font size: 18px
            $(this).css("font-size","18px");
    });
    // on mousedown
    $(".x-table td").mousedown(function() {
    // background color: yellow
             $(this).css("background-color","yellow");
    //font size: 18px        
             $(this).css("font-size","18px");
    });
    // on mouseout
    $(".x-table td").mouseout(function() {
    // background color: white
            $(this).css("background-color","white");
    //font size: 12px 
            $(this).css("font-size","12px");
    });

    3) Click [Data Entry Preview] to see the effect:


    2.2 Sample 2: Restyle the row the mouse moves over

    Rewrite the JavaScript codes for the Load End event added in the above template:

    // on mousemove
    $(".x-table tr").mousemove(function() {
    // background color: red
            $(this).css("background-color","red");
    //font size: 18px
            $(this).find("td").css("font-size","18px");
    });
    // on mousedown
    $(".x-table tr").mousedown(function() {
    // background color: yellow
            $(this).css("background-color","yellow");
    //font size: 18px        
            $(this).find("td").css("font-size","18px");
    });
    //on mouseout
    $(".x-table tr").mouseout(function() {
    // background color: white
            $(this).css("background-color","white");
    //font size: 12px 
            $(this).find("td").css("font-size","12px");
    });

    Click [Data Entry Preview] to see the effect:

     

    III. Download the templates

    1) Sample 1: Restyle the cell the mouse moves over

    1.cpt

     

    2) Sample 2: Restyle the row the mouse moves over

    2.cpt

     

    Refer to the original link: https://help.finereport.com/doc-view-1907.html

     


    Attachment List


    Theme: Data Entry
    • 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