# 印刷画面での文字色の変更について

**URL:** <https://community.cybozu.dev/t/topic/1615>\
**Category:** kintone 開発相談\
**Created:** [2023 年 5 月 30 日午前 12:28 UTC](https://community.cybozu.dev/t/topic/1615 "2023-05-30T00:28:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Legacy\_Account6](https://avatars.discourse-cdn.com/v4/letter/l/8e8cbc/32.png) [@Legacy\_Account6](https://community.cybozu.dev/u/Legacy_Account6)\
**Post date:** [2023 年 5 月 30 日午前 12:28 UTC](https://community.cybozu.dev/t/topic/1615/1 "2023-05-30T00:28:36Z")

</div>

(function() {  
&nbsp; ‘use strict’;  
&nbsp; kintone.events.on(‘app.record.print.show’, function(event) {  
&nbsp; &nbsp; const fields = [‘分納・報告書’, ‘受付番号’, ‘ブロック数の合計’, ‘染色枚数の合計’];

&nbsp; &nbsp; for (let i = 0; i \< fields.length; i++) {  
&nbsp; &nbsp; &nbsp; const field = fields[i];  
&nbsp; &nbsp; &nbsp; const element = kintone.app.record.getFieldElement(field);  
&nbsp; &nbsp; &nbsp; if (element) {  
&nbsp; &nbsp; &nbsp; &nbsp; element.style.backgroundColor = ‘#f5f5f5’;  
&nbsp; &nbsp; &nbsp; &nbsp; element.style.color = ‘red’;  
&nbsp; &nbsp; &nbsp; &nbsp; if (field === ‘ブロック数の合計’ || field === ‘染色枚数の合計’) {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; element.style.border = ‘1px solid #ccc’; // 枠線を表示する  
&nbsp; &nbsp; &nbsp; &nbsp; } else {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; element.style.border = ‘none’; // 枠線を非表示にする  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; element.style.fontSize = ‘30px’; // 文字の大きさを30pxにする  
&nbsp; &nbsp; &nbsp; &nbsp; }  
&nbsp; &nbsp; &nbsp; }  
&nbsp; &nbsp; }  
&nbsp; });  
})();

上記のコードで印刷画面おいて文字色の変更・文字サイズの変更・枠線の非表示が行たのですが、それはフィールドが単体のもだけにしか滝用できませんでした。当方がやりたいことはテーブル内のフィールドにも印刷画面おいて文字色の変更をしたいのですが、どなたかお知恵をお貸しいただけないでしょうか。

---

<div class="post-metadata">

**Author:** ![Legacy\_Account1177](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@Legacy\_Account1177](https://community.cybozu.dev/u/Legacy_Account1177)\
**Post date:** [2023 年 5 月 30 日午前 1:42 UTC](https://community.cybozu.dev/t/topic/1615/2 "2023-05-30T01:42:20Z")

</div>

[kintone.app.record.getFieldElement()](https://cybozu.dev/ja/kintone/docs/js-api/record/get-record-field-element/)の「nullになる条件」に記載してありますが、サブテーブル内のフィールドを指定することができません。  
サブテーブル自体は取得できるので、サブテーブルを取得後[querySelectorAll(‘td’)](https://developer.mozilla.org/ja/docs/Web/API/Document/querySelectorAll)等を実行すればサブテーブル内のフィールドにもアクセスできますが、制限事項に「取得した DOM の内部構造を変更するような処理を行うと、kintone のバージョンアップ後に動作しなくなる可能性があります。」とある通り、フロントエンド刷新後も動作が確実に保証されているわけではないので、今後のアップデートで対応が必要になるかもしれません。

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/cybozu/original/1X/d5c841c3c5a6cb66eed514001c1b45147c9e1f4f.png) [@system](https://community.cybozu.dev/u/system)\
**Post date:** [2023 年 9 月 29 日午前 1:27 UTC](https://community.cybozu.dev/t/topic/1615/3 "2023-09-29T01:27:46Z")

</div>

クローズされました: 2023 年 9 月 29 日午前 1:27 UTC

このトピックはベストアンサーに選ばれた返信から 3 日が経過したので自動的にクローズされました。新たに返信することはできません。
