Top > 開発ガイド > コンポーネント開発Tips集 > エクスポートウィンドウ
エクスポートウィンドウ
対象バージョン
当ドキュメントはRubricks-0.6.x向けです。
概要
データのエクスポートを行う際、確認ウィンドウ等を使うと、IEでエクスポートが正常にできない場合があります。そのため、エクスポート用のウィンドウを表示するためのヘルパを用意しました。
利用方法
記述例
<%= 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 => 'サンプルデータ'}})%>
API
render_export_window(options)
- options
:element_id WindowエレメントのDOM ID。 :js_options Windowを構築するためのオプション。(参照:Window) :title Windowのタイトル。(デフォルト:「エクスポート」) :variable Windowインスタンスを格納する変数。 :contents エクスポートウィンドウ内に表示される内容。
- :contents
:message エクスポートに関する注意書き。 :prefix エクスポートウィンドウ内に配置される各種エレメントのDOM ID接頭辞。 :target エクスポート対象の値として表示される文字列 :type 出力形式の値として表示される文字列(デフォルト:CSV)
render_export_window(element_id, variable, title, js_options, contents)
- それぞれの引数が上記オプションの同一keyに対応します。
render_export_window(options, &block)
- 上記の形式ではカバー仕切れない場合は、ブロック形式で自由に書くことも可能です。
- options
:element_id WindowエレメントのDOM ID。 :js_options Windowを構築するためのオプション。(参照:Window) :title Windowのタイトル。(デフォルト:「エクスポート」) :variable Windowインスタンスを格納する変数。
- 記述例
<% 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();"})} <table class="rubricks_general_table"> <tr class="rubricks_general_table_even"> <td><%= hl('[_Common_ExportTarget]') %></td> <td>サンプルデータ</td> </tr> <tr class="rubricks_general_table_even"> <td><%= hl('[_Common_ExportType]') %></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(hl('[_Common_Yes]'), {: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="<%= hl('[_Common_No]') %>" onclick="rubricks.sample.export_window.close();"> <%= rollover_swap("sample_export_button", "sample_export_cancel_button") %> </p> <% end %> <% end %>
