yasumori
(yasumori)
1
テーブルの追加削除を行っているボタンについて、左側に表示をしたいです。
以前まで下記コードのCSSにてボタンの移動が出来ておりましたが、
最近kintoneの仕様が変わり、ボタンが元通りの右側に移動・テーブルの枠付きの表示に変更になっておりました。
CSSの変更箇所、CSS以外のカスタマイズ方法についてご教示いただけませんでしょうか。
横長のテーブルだと右側にボタンがあると不便なため、標準で左側に表示をしていただければ助かるのですが。。。
※以前まで「subtable-operation-gaia-old」というタグの名称だったのため、「subtable-operation-gaia」に変更しましたが、
左側に移動できませんでした。
.subtable-row-label-gaia{
padding-left:74px;
}
.subtable-gaia.edit-subtable-gaia{
margin-left:64px;
}
.subtable-gaia.edit-subtable-gaia > tbody > tr{
position:relative;
}
.subtable-gaia.edit-subtable-gaia > tbody > tr > td.subtable-operation-gaia-old{
position:absolute;
left:-64px;
top:0;
}
.subtable-gaia.edit-subtable-gaia > tbody > tr > td.subtable-operation-gaia-old .add-row-image-gaia{
margin-left:0 !important;
}
.subtable-gaia.edit-subtable-gaia > tbody > tr > td.subtable-operation-gaia-old .remove-row-image-gaia{
margin-right:12px;
}
jurippe
(jurippe)
2
以前はどうだったか忘れちゃったんですが、
追加削除ボタンが列の中に入ってしまっているので、CSSだけでは難しいかもしれませんね
danke
3
フレックスボックスを使用すればCSSだけでもボタンの移動はできましたが、レイアウトが崩れるので、CSSのみはあまり推奨はできないですね。
私もプログラミングに詳しくなく、手探りでやっていたのでおかしなところがあるかもしれませんが、こんな感じでできました。
css
/* テーブル全体のスタイル */
.subtable-gaia.edit-subtable-gaia {
width: 100%;
}
/* 操作列を左端に移動 /
.subtable-gaia.edit-subtable-gaia thead th.subtable-operation-gaia,
.subtable-gaia.edit-subtable-gaia tbody td.subtable-operation-gaia {
order: -1; / 操作列を左端に移動 */
text-align: center;
}
/* 各行をフレックスボックスに */
.subtable-gaia.edit-subtable-gaia thead tr,
.subtable-gaia.edit-subtable-gaia tbody tr {
display: flex;
}
/* 各列をフレックスボックスで配置 /
.subtable-gaia.edit-subtable-gaia thead th,
.subtable-gaia.edit-subtable-gaia tbody td {
flex: 1;
text-align: center;
white-space: nowrap; / 内容が折り返されないように /
box-sizing: border-box; / 幅計算の一貫性を保つ */
}
/* 操作列に固定幅を指定 */
.subtable-gaia.edit-subtable-gaia th.subtable-operation-gaia,
.subtable-gaia.edit-subtable-gaia td.subtable-operation-gaia {
flex: 0 0 80px;
}
js
document.addEventListener(“DOMContentLoaded”, function () {
const table = document.querySelector(“.subtable-gaia.edit-subtable-gaia”);
if (table) {
const headerCells = table.querySelectorAll("thead th");
// 列幅を同期する関数
function syncColumnWidths() {
const bodyRows = table.querySelectorAll("tbody tr");
// ヘッダーの列幅を取得し、ボディに適用
headerCells.forEach((headerCell, index) => {
const headerWidth = headerCell.offsetWidth;
bodyRows.forEach((row) => {
const bodyCell = row.children[index];
if (bodyCell) {
bodyCell.style.flex = `0 0 ${headerWidth}px`;
}
});
});
}
// 初期同期
syncColumnWidths();
// 行が追加されるたびに同期を実行
const observer = new MutationObserver(() => {
syncColumnWidths();
});
// tbody に対して監視を開始
const tbody = table.querySelector("tbody");
if (tbody) {
observer.observe(tbody, { childList: true });
}
}
});
環境や今後のアップデートで変わると思いますが、参考になれば。
「いいね!」 1
yasumori
(yasumori)
4
ご返信いただきありがとうございます。
ソースまで記載いただき感謝です。
一度、いただいたソースを使って試してみようと思います。
system
(system)
クローズされました:
5
このトピックはベストアンサーに選ばれた返信から 3 日が経過したので自動的にクローズされました。新たに返信することはできません。