JS Radio button group middle and center aligned in cell

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

    1.1 Problem

    When the cell is large, the radio button group widget will not be centered horizontally or vertically.

    image.png


    1.2 Solution

    We can use JS to obtain the object, and change its CSS style.

    image (1).png

    II. Example

    Add a radio button group widget to the cell. Set customized data dictionary. Check [Adaptive].

    image (2).png

    Adjust the cell width and height, add a border to the cell.

    image (3).png

    Add an after initialization event to the widget. Enter the following JS:

    image (4).png

    var el = $(this.element);
    var f = function() {
    var w = 0;
    var cs = el.children();
    if (cs.length == 0) {
      setTimeout(f, 100);
      return;
    }
    for (var i=0; i<cs.length; i++) {
      w += cs.eq(i).width() + 5;
    }
    el.css({
      width: w,
      'margin-left': 'auto',
      'margin-right': 'auto',
      'height':' auto', 
    });
    }
    setTimeout(f, 100);

    Save and data entry preview:

    image (1).png

    III. Download template

    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