# スペースフィールドに追加したボタンをdisableにしたい

**URL:** <https://community.cybozu.dev/t/topic/4173>\
**Category:** kintone 開発相談\
**Created:** [2019 年 6 月 21 日午前 2:35 UTC](https://community.cybozu.dev/t/topic/4173 "2019-06-21T02:35:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Legacy\_Account1067](https://avatars.discourse-cdn.com/v4/letter/l/8797f3/32.png) [@Legacy\_Account1067](https://community.cybozu.dev/u/Legacy_Account1067)\
**Post date:** [2019 年 6 月 21 日午前 2:35 UTC](https://community.cybozu.dev/t/topic/4173/1 "2019-06-21T02:35:51Z")

</div>

お世話になります。

[こちらの記事](https://community.cybozu.dev/hc/ja/articles/201952870-%E7%AC%AC3%E5%9B%9E-%E3%83%AC%E3%82%B3%E3%83%BC%E3%83%89%E8%A9%B3%E7%B4%B0%E3%81%AB%E3%82%82%E3%83%9C%E3%82%BF%E3%83%B3%E3%82%92%E8%A8%AD%E7%BD%AE%E3%81%97%E3%82%88%E3%81%86-)の「ボタンの設置（２）」を参考にして詳細画面にスペースフィールドを用意し、ラベルとドロップダウンを追加しました。

この追加したドロップダウンのdisableを別のラジオボタンの選択値によって制御したいのですがどのように書けばよいかわかりません。

どなたかアドバイスをいただけますと幸いです。

よろしくお願いいたします。&nbsp;

---

<div class="post-metadata">

**Author:** ![Legacy\_Account1740](https://avatars.discourse-cdn.com/v4/letter/l/ed8c4c/32.png) [@Legacy\_Account1740](https://community.cybozu.dev/u/Legacy_Account1740)\
**Post date:** [2019 年 6 月 21 日午前 3:59 UTC](https://community.cybozu.dev/t/topic/4173/2 "2019-06-21T03:59:09Z")

</div>

Asami.w様

お世話になっております。  
cstapの江田と申します。

ドロップダウンはどのように作成していますか？

よろしければ、コードを提示いただけると回答しやすいかと思います。

---

<div class="post-metadata">

**Author:** ![Legacy\_Account1067](https://avatars.discourse-cdn.com/v4/letter/l/8797f3/32.png) [@Legacy\_Account1067](https://community.cybozu.dev/u/Legacy_Account1067)\
**Post date:** [2019 年 6 月 21 日午前 4:12 UTC](https://community.cybozu.dev/t/topic/4173/3 "2019-06-21T04:12:48Z")

</div>

江田様 ご返信ありがとうございます。

コードですが下記のようになってます（抜粋です）

&nbsp;

//ドロップダウン用の変数

var tantoDropDown;

&nbsp;

//入力画面表示イベント

kintone.events.on([‘app.record.create.show’,‘app.record.edit.show’],function(event) {

&nbsp; &nbsp; var record = event.record;

（略）

&nbsp; &nbsp; //担当者選択  
&nbsp; &nbsp; var label = new kintoneUIComponent.Label({text: ‘担当者の選択’});  
&nbsp; &nbsp; tantoDropDown= new kintoneUIComponent.Dropdown({items:[]});

&nbsp; &nbsp; kintone.app.record.getSpaceElement(‘selectSupport’).appendChild(label.render());  
&nbsp; &nbsp; kintone.app.record.getSpaceElement(‘selectSupport’).appendChild(tantoDropDown.render());

});

&nbsp;

//ラジオボタン変更イベント

kintone.events.on([‘app.record.create.change.区分’,‘app.record.edit.change.区分’], function(event) {

&nbsp; &nbsp; var record = event.record;

&nbsp; &nbsp; //区分によりテキストフィールドの入力制御等

&nbsp; &nbsp; if ( record[‘区分’] === ‘選択値’ ) {

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;record[‘コード’].disabled = true;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//TODO ここでtantoDropdownのdisableも制御したい

&nbsp; &nbsp; }

&nbsp; &nbsp; return event;  
});

&nbsp;

「区分」ラジオボタンの選択値により、tantoDropdownの入力を制限したいです。

何卒よろしくお願いします。

---

<div class="post-metadata">

**Author:** ![Legacy\_Account1740](https://avatars.discourse-cdn.com/v4/letter/l/ed8c4c/32.png) [@Legacy\_Account1740](https://community.cybozu.dev/u/Legacy_Account1740)\
**Post date:** [2019 年 6 月 21 日午前 4:20 UTC](https://community.cybozu.dev/t/topic/4173/4 "2019-06-21T04:20:06Z")

</div>

Asami.w様

お世話になっております。

kintone UI Componentで作成しているのであれば、「tantoDropdown.disable();」でdisableにできると思います。[https://kintone.github.io/kintone-ui-component/latest/Reference/Dropdown/#disable](https://kintone.github.io/kintone-ui-component/latest/Reference/Dropdown/#disable)

```
//ラジオボタン変更イベント

kintone.events.on(['app.record.create.change.区分','app.record.edit.change.区分'], function(event) {

    var record = event.record;

    //区分によりテキストフィールドの入力制御等

    if ( record['区分'] === '選択値' ) {

         record['コード'].disabled = true;

         //TODO ここでtantoDropdownのdisableも制御したい
         tantoDropdown.disable();

    }

    return event;
});

```

---

<div class="post-metadata">

**Author:** ![Legacy\_Account1067](https://avatars.discourse-cdn.com/v4/letter/l/8797f3/32.png) [@Legacy\_Account1067](https://community.cybozu.dev/u/Legacy_Account1067)\
**Post date:** [2019 年 6 月 21 日午前 4:37 UTC](https://community.cybozu.dev/t/topic/4173/5 "2019-06-21T04:37:18Z")

</div>

江田様

お世話になっております。

ご教示いただいた方法で制御できました。

componentのドキュメントを見直したらdisable/enableについても記載されておりましたね。

ドキュメントももっときちんと読むようにいたします。

&nbsp;

ご教示ありがとうございました。
