0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【kintone】一覧画面でフィールドの幅が広くても枠からはみ出ないようにする

Last updated at Posted at 2025-07-16

一覧は横幅が一画面に収まらないほど長いと、下図のように枠からはみ出てしまう。
無題ち.png

このはみ出しが起こらないようにする。

本記事の投稿日に動くことは確認しているが、公式が非推奨とするDOM操作なので
else節のエラーが出るなら、アップデートでHTML要素が変わっている可能性が高い。

(() => {
  'use strict';

  // 一覧画面で以下の要素が描画された後に処理開始
  kintone.events.on('app.record.index.show', (event) => {
    requestAnimationFrame(() => {
      const container = document.querySelector('.container-gaia.app-index-container-gaia');
      const reference = document.getElementById('view-list-data-gaia');

      if (container && reference) {
        // 枠の幅を一覧の幅に合わせる
        container.style.width = `${reference.offsetWidth}px`;

        // 一覧の幅が変わったら、枠も同じ幅に変更する
        const observer = new ResizeObserver(() => {
          container.style.width = `${reference.offsetWidth}px`;
        });
        observer.observe(reference);
      // 要素の取得に失敗した場合の例外処理
      } else {
        console.warn('同期失敗:container または reference が見つかりませんでした');
      }
    });

    return event;
  });
})();
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?