JS ラジオボタングループの位置と配列を設定する

  • 作成者:ayuan0625
  • 編集回数:11次
  • 最終更新:ayuan0625 于 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: FineReport カスタム開発
    • いいね
    • 良くない
    • 閲覧しただけ