Top > 開発ガイド > コンポーネント開発逆引きリファレンス > エクスポートウィンドウを表示する
エクスポートウィンドウを表示する
対象バージョン
当ドキュメントはRubricks-0.6.x向けです。
概要
データのエクスポートを行う際、確認ウィンドウ等を使うと、IEでエクスポートが正常にできない場合があります。
そのため、エクスポート用のウィンドウを表示するためのヘルパを用意しました。
イメージ
使い方
Viewでrender_export_windowを呼び出してエクスポート用のウィンドウを表示します。
<%= render_export_window({:element_id => 'sample_export_window_id',
:variable => 'rubricks.sample.export_window',
:contents => {:form_url_options => {:controller => '/sample/index', :action => 'export'},
:message => 'サンプルデータのエクスポートをします。エクスポートを実行してよろしいですか?',
:prefix => 'sample_export_',
:target => 'サンプルデータ'}})%>
上記の形式ではカバー仕切れない場合は、以下のようにエクスポートウィンドウの中身をブロック形式で自由に書くことも可能です。
<!--エクスポートウィンドウを表示する-->
<% render_export_window({:element_id => 'sample_export_window_id', :variable => 'rubricks.sample.export_window'}) do %>
<!--ウィンドウの内容-->
<% form_tag({:controller => '/sample/index', :action => 'export'},
{:id => "sample_export_form", :onsubmit => "rubricks.sample.export_window.close();"}) do %>
<table class="rubricks_general_table">
<tr class="rubricks_general_table_even">
<td>エクスポート対象</td>
<td>サンプルデータ</td>
</tr>
<tr class="rubricks_general_table_even">
<td>出力形式</td>
<td>CSV</td>
</tr>
</table>
<p id="sample_export_message" class="export_window_message">サンプルデータのエクスポートをします。エクスポートを実行してよろしいですか?</p>
<p style="padding-right:20px; text-align:right;">
<!--エクスポートの実行が承諾された場合フォームをサブミットする-->
<%= submit_tag('はい', {:id => "sample_export_button", :class => 'submit_inactive submit_normal swap'}) %>
<!--エクスポートの実行をキャンセルした場合エクスポートウィンドウを閉じる-->
<input type="button" id="sample_export_cancel_button" class="submit_inactive submit_normal swap" value="いいえ" onclick="rubricks.sample.export_window.close();">
<%= rollover_swap("sample_export_button", "sample_export_cancel_button") %>
</p>
<% end %>
<% end %>
関連項目
API
render_export_window(options)
- エクスポートウィンドウを描画します。
| 引数 | 必須 | 初期値 | 型 | 説明 |
| options | ○ | - | Hash | エクスポートウィンドウ表示のオプションです。下記「オプション」を参照してください。 |
オプション:
| キー | 必須 | 初期値 | 型 | 説明 | ||||
| :element_id | ○ | - | String | WindowエレメントのDOM-ID。 | ||||
| :js_options | - | - | Hash | Windowを構築するためのオプション。(参照:Window) | ||||
| :title | - | 'エクスポート' | String | Windowのタイトル。 | ||||
| :variable | ○ | - | String | Windowインスタンスを格納する変数。 | ||||
| :contents | - | - | Hash | エクスポートウィンドウ内に表示される内容。 | ||||
| キー | 必須 | 初期値 | 型 | 説明 | ||||
| :message | - | - | String | エクスポートに関する注意書き。 | ||||
| :prefix | - | - | String | エクスポートウィンドウ内に配置される各種エレメントのDOM-ID接頭辞。 | ||||
| :target | - | - | String | エクスポート対象の値として表示される文字列 。 | ||||
| :type | - | 'CSV' | String | 出力形式の値として表示される文字列。 | ||||
render_export_window(element_id, variable, title, js_options, contents)
- それぞれの引数が上記オプションの同一keyに対応します。
render_export_window(options, &block)
- ブロック形式でエクスポートウィンドウの内容を指定することができます。
| 引数 | 必須 | 初期値 | 型 | 説明 |
| options | ○ | - | String | エクスポートウィンドウのオプションです。下記「オプション」を参照してください。 |
| &block | - | - | - |
オプション:
| キー | 必須 | 初期値 | 型 | 説明 | ||||
| :element_id | ○ | - | Hash | WindowエレメントのDOM-ID。 | ||||
| :js_options | - | - | Hash | Windowを構築するためのオプション。(参照:Window) | ||||
| :title | - | 'エクスポート' | String | Windowのタイトル。 | ||||
| :variable | ○ | - | String | Windowインスタンスを格納する変数。 | ||||
Attachments
- export_window.jpg (25.4 kB) - added by uchida on 03/19/09 11:23:33.

