Top > 開発ガイド > コンポーネント開発Tips集 > Spinelzヘルパ > render_selectable_table

render_selectable_table

概要

利用方法

記述例

<% render_selectable_table('sample_selectable_table_id', 'rubricks.sample.selectable_table', {
  :html_options => {
    :style => 'width:100%;'
  },
  :js_options   => {
    :functionSubmit => 'function(el) {alert(el);}',
    :prefixTrId     => 'sample_selectable_table_',
  },
}) do %>
  <tbody>
    <% @sample_models.each do |sample_model| %>
      <% render_selectable_tr(sample_model.id) do %>
        <% render_selectable_td do %>
          <%= hl(sample_model.content) %>
        <% end %>
      <% end %>
    <% end %>
  </tbody>
<% end %>

上記の記述は、Selectable Tableを直接利用して、下記のように記述することと同じ結果が得られます。

<table id="sample_selectable_table_id" style="width:100%; visibility:hidden;">
  <tbody>
    <% @sample_models.each do |sample_model| %>
      <tr id="<%= sample_model.id %>">
        <td>
          <%= hl(sample_model.content) %>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>
<script type="text/javascript">
  rubricks.sample.selectable_table = SelectableTableCreator.create(
    'sample_selectable_table_id',
    {
      functionSubmit:   function(el) {alert(el);},
      prefixTrId:       'sample_selectable_table_'
    },
    sample_selectable_table
  );
</script>

API

render_selectable_table(element_id, variable, options = {}, &block)

引数説明
element_id生成されるTableタグのDOM ID
variableインスタンスを格納する変数
optionsSelectable Tableを構築するためのオプション

オプション

オプション名説明
html_optionsTableタグのAttribute
js_optionsSelectable Tableに渡されるオプション(参照)
manageSelectable Tableの管理を行うか否か(参照)

render_selectable_tr(element_id, options = {}, &block)

引数説明
element_id生成されるTrタグのDOM ID(AR#idを想定)
optionsTrタグのAttribute

render_selectable_td(options = {}, &block)

引数説明
optionsTdタグのAttribute