JS Control Height and Number of Drop-down Box Options

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

    1.1 Problem description

    When selecting data, there are cases where the options in the drop-down box are all numbers or letters and there are particularly many options. Since the upper and lower intervals of the options in the drop-down box are small, users may face difficulties to identify these options. The recognizability can be improved by increasing the line spacing of the options, as shown below:

    image.png


    1.2 Implementation ideas

    Set the line spacing of options through this.options.sonHeight;

    Use this.options.maxCount to set the number of options displayed in the drop-down box.

    II. Example

    2.1 Example 1: Set the line spacing of drop-down options

    1) Select the drop-down box of the parameter panel and add a After Initialization event, as shown below:

    3.png

    The JavaScript code is as follows:

    this.options.sonHeight=30; //Limit the line height to 30px

    Preview effect:

    image (1).png


    2.2 Example 2: Control the number of options displayed in the drop-down box

    If the drop-down box has a large number of options, in order to make the filling interface more concise, you can limit the number of directly displayed options through JavaScript code, and display the rest through scroll bars.

    As shown in the figure below,  after the code of previous example, add a line of code that limits the number of widgets directly displayed:

     4.png

    this.options.maxCount=4; // 4 is the limited number of options to be displayed directly

    The effect is as follows:

    5.gif

    Note: The two examples in this article do not support mobile terminals.

    III. Completed Template

    Attachment List


    Theme: Parameter
    • 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