Sha256: 8b5fe673c01aea8cb2e1d130b0f34b4c6c8bfd87cb64101140d02cef3565f803

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

<table<%= config.to_a.map { |attr| " #{attr.first}=\"#{h attr.last}\""}.join ' ' %>>
  <thead>
    <% columns.each do |column| %>
    <th><%= column[:display_name] %></th>
    <% end %>
  </thead>
  <tbody></tbody>
  <% if filterable.any? %>
  <tfoot>
    <% columns.each do |column| %>
    <th>
      <% if column[:column_filtering] %>
        <input type="text" placeholder="<%= column[:display_name] %>" id="<%=h config[:id] %>-column-filter-<%=h column[:name] %>" />
      <% else %>
        &nbsp;
      <% end %>
    </th>
    <% end %>
  </tfoot>
  <% end %>
</table>

<script type="text/javascript">
  $(document).ready( function() {
      var table = $('#<%= config[:id] %>').DataTable({
          ajax: "<%=h serverside_path %>",
          serverSide: true,
          processing: true
      });

      <% if filterable.any? %>
      table.columns().every( function () {
          var that = this;

          $( 'input', this.footer() ).on( 'keyup change', function () {
              if ( that.search() !== this.value ) {
                  that.search( this.value ).draw();
              }
          } );
      } );
      <% end %>
  });
</script>

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails_serverside_datatables-0.1.3 lib/rails_serverside_datatables/views/datatable.html.erb
rails_serverside_datatables-0.1.2 lib/rails_serverside_datatables/views/datatable.html.erb
rails_serverside_datatables-0.1.1 lib/rails_serverside_datatables/views/datatable.html.erb