# サブテーブルの追加削除ボタンの位置変更について

**URL:** <https://community.cybozu.dev/t/topic/9982>\
**Category:** kintone 開発相談\
**Created:** [2025 年 1 月 18 日午後 12:17 UTC](https://community.cybozu.dev/t/topic/9982 "2025-01-18T12:17:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![y.takatsuki](https://avatars.discourse-cdn.com/v4/letter/y/8e8cbc/32.png) [@y.takatsuki](https://community.cybozu.dev/u/y.takatsuki)\
**Post date:** [2025 年 1 月 18 日午後 12:17 UTC](https://community.cybozu.dev/t/topic/9982/1 "2025-01-18T12:17:23Z")

</div>

サブテーブルの追加削除（＋、－）ボタンの位置を変更していたのですが、  
昨年10月14日にKintoneの仕様変更で"subtable-operation-gaia"が  
"subtable-operation-gaia-old"になったため、その対応を行っていました。  
今回、1月16日にボタンの位置が戻っていたため、確認したところ、  
“subtable-operation-gaia-old"が元の"subtable-operation-gaia"に戻っていました。  
それで、コーディングにつていも、”-old"を削除したのですが、うまくいきません。  
コーディングは以下の通りです。

```javascript
function setRowButton(valueYear,valueMonth) {
  const style = document.createElement('style');
  let setIntervalID = setInterval(() => {
    [].forEach.call(
      document.getElementsByClassName("subtable-gaia")[1].getElementsByClassName("subtable-operation-gaia"),
      (button) => {
        // 今月の最終日を取得
        let endMonth = new Date(valueYear, valueMonth, 0);
        let endDay = endMonth.getDate();
        let styleMarginLeft = '-2058px';
        // 最終日に応じてマージンを調整
        if (endDay == 30) {
            styleMarginLeft = '-2008px';
        } else if (endDay == 29) {
            styleMarginLeft = '-1958px';
        } else if (endDay == 28) {
            styleMarginLeft = '-1908px';
        }
        button.style.position = 'absolute';
        button.style.marginLeft = styleMarginLeft;
      }
    );
    clearInterval(setIntervalID);
  }, 500);
}

```

このコーディングで、marginLeftは無効になるのですが、  
試しにmarginRightを使ったところ、有効になります。  
marginRightでは、追加削除（＋、－）ボタンの位置が固定できないので、  
いい方法がないかと悩んでいます。  
すみません、いい方法を教えていただけないでしょうか。  
毎月の月末の日付でボタンの位置を調整しているため、CSSではなく、  
JSで対応したいと思います。

ちなみに、CSSで  
element,style {  
right: 0px;  
position : absolute;  
margin-left: -2058px;  
}  
となるのですが、この"right: 0px"を無効化すると"margin-left: -2058px"が  
有効になるようです。  
よろしくお願いします。

すみません、自己解決しました。  
button.style.right = ‘unset’; を入れることでmarginLeftが有効になりました。

---

<div class="post-metadata">

**Author:** ![Staff-sushi](https://sea1.discourse-cdn.com/flex015/user_avatar/community.cybozu.dev/staff-sushi/32/24_2.png) [@Staff-sushi](https://community.cybozu.dev/u/Staff-sushi)\
**Post date:** [2025 年 1 月 24 日午前 4:16 UTC](https://community.cybozu.dev/t/topic/9982/2 "2025-01-24T04:16:37Z")

</div>


