メインメニュー > よくあるご質問 > 文書の参照ページで、フィールドの代わりに表を表示するようにしたい

よくあるご質問

Print Prev Next

文書の参照ページで、フィールドの代わりに表を表示するようにしたい

2016年 2月 25日作成
2019年 9月 17日更新

smaconne のフォーム情報では、通常フィールド1つずつを割り当てるように設定しますので、Notes のフォームで表組をして表示しているものでも以下のような表示となります。
表組表示なし

これを Notes と同じように以下のような表組で表示するようにする方法について記載します。
表組表示あり


上記のスクリーンキャプチャにあるように、Notes のフォームでは、乗車駅、降車駅、片道旅費、片道/往復の別、メモの5つで1行を構成するようになっています。
各列の内容は以下の通りです。

フィールドの見出し
名前種類制御等
乗車駅/降車駅
station01~station16テキスト

片道旅費
fee1~fee8
数値
\#,##0
片道/往復の別
return_sw1~return_sw8
ラジオボタン
片道|0
往復|1
メモ
memo1~memo8
テキスト


smaconne のフォーム情報で、任意の場所にフィールド行を挿入して、ラベル名に「明細」と入力し、フィールド名には何も指定せず、式に以下の表を表示する HTML コードを生成する式を設定します。
なお、以下のサンプルコードでは、乗車駅と降車駅が共に未入力の行は表示しないようにしています。

tmp_0 := {<table border="0" cellpadding="0" cellspacing="0"><tr><th>乗車駅</th><th>降車駅</th><th>片道旅費</th><th>片道/往復</th><th>メモ</th></tr>};
tmp_9 :={</table>};
tmp := "";
@For(n := 1; n <= 8; n := n + 1;
tmpFrom := @If( n < 6; @GetField( "station0" + @Text( n * 2 - 1 ) ); @GetField( "station" + @Text( n * 2 - 1 ) ) );
tmpTo := @If( n < 5; @GetField( "station0" + @Text( n * 2 ) ); @GetField( "station" + @Text( n * 2 ) ) );
tmpFee := @GetField( "fee" + @Text( n ) );
tmpReturn := @GetField( "return_sw" + @Text( n ) );
tmpMemo := @GetField( "memo" + @Text( n ) );
@If( tmpFrom != "" & tmpTo != "";
tmp := tmp + {<tr>
<td style="background: #f0f0f0;">} + tmpFrom + {</td>
<td>} + tmpTo + {</td>
<td style="background: #f0f0f0;">} + @Text( tmpFee; "C,0" ) + {</td>
<td>} + @If( tmpFee = 0; ""; @If( tmpReturn = "0"; "片道"; tmpReturn = "1"; "往復"; "" ) ) + {</td>
<td style="background: #f0f0f0;">} + tmpMemo + {</td>
</tr>};
tmp := tmp
)
);
tmp_0 + tmp + tmp_9


smaconne のアプリ設定文書を保存して、smaconne を再表示すると、以下のイメージのように表組で表示されます。
表組表示あり

以上


ご参考:

Print Prev Next












© 2024 ケートリック株式会社