Sha256: 4ab7afa3d62084ac7b1a6944b035790f887211e524f517ca94fbbda4f92e673b

Contents?: true

Size: 1.93 KB

Versions: 17

Compression:

Stored size: 1.93 KB

Contents

:ruby
  effective_datatable_params = {
    :id => "#{datatable.to_param}-table",
    :class => ('table ' + table_class.to_s),
    :cellpadding => 0,
    :cellspacing => 0,
    :border => 0,
    :width => '100%',
    :data => {
      'effective-datatables-table' => style,
      'source' => effective_datatables.datatable_path(datatable, {:format => 'json'}.merge(:attributes => datatable.attributes)).chomp('?'),
      'column-names' => datatable_column_names(datatable),
      'non-sortable' => datatable_non_sortable(datatable, sortable),
      'non-visible' => datatable_non_visible(datatable),
      'widths' => datatable_widths(datatable),
      'default-order' => datatable_default_order(datatable),
      'display-entries' => datatable.display_entries,
      'display-records' => (datatable.to_json[:recordsFiltered] || 0),
      'total-records' => (datatable.to_json[:recordsTotal] || 0),
      'column-classes' => datatable_column_classes(datatable),
      'effective-form-inputs' => defined?(EffectiveFormInputs)
    }
  }

  form_builder = nil
  simple_form_for(datatable, url: '#', html: {id: "#{datatable.to_param}-form"}) { |f| form_builder = f }

%table.effective-datatable{effective_datatable_params}
  %thead
    - max_depth = datatable.table_columns.map { |_, opts| opts[:th][:depth].to_i rescue 0 }.max
    - [*0..max_depth].each do |depth|
      %tr
        - table_columns = datatable.table_columns.select { |_, opts| (opts[:th][:depth] || 0 rescue 0) == depth }
        - table_columns.each do |name, opts|
          %th{(opts[:th] || {}).merge({:title => opts[:label] || name})}
            = render_datatable_header_cell(form_builder, name, opts, filterable)
          - (opts[:append_th] || []).each do |faux_col|
            %th{(faux_col[:th] || {}).merge({:title => faux_col[:label]})}
              = faux_col[:label]
  %tbody
    - (datatable.to_json[:data] || []).each do |row|
      %tr
        - row.each do |col|
          %td= col.to_s.html_safe

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
effective_datatables-2.1.20 app/views/effective/datatables/_datatable.html.haml
effective_datatables-2.1.19 app/views/effective/datatables/_datatable.html.haml
effective_datatables-2.1.18 app/views/effective/datatables/_datatable.html.haml
effective_datatables-2.1.16 app/views/effective/datatables/_datatable.html.haml
effective_datatables-2.1.15 app/views/effective/datatables/_datatable.html.haml
effective_datatables-2.1.14 app/views/effective/datatables/_datatable.html.haml
effective_datatables-2.1.13 app/views/effective/datatables/_datatable.html.haml
effective_datatables-2.1.12 app/views/effective/datatables/_datatable.html.haml
effective_datatables-2.1.11 app/views/effective/datatables/_datatable.html.haml
effective_datatables-2.1.10 app/views/effective/datatables/_datatable.html.haml
effective_datatables-2.1.9 app/views/effective/datatables/_datatable.html.haml
effective_datatables-2.1.8 app/views/effective/datatables/_datatable.html.haml
effective_datatables-2.1.7 app/views/effective/datatables/_datatable.html.haml
effective_datatables-2.1.6 app/views/effective/datatables/_datatable.html.haml
effective_datatables-2.1.5 app/views/effective/datatables/_datatable.html.haml
effective_datatables-2.1.4 app/views/effective/datatables/_datatable.html.haml
effective_datatables-2.1.3 app/views/effective/datatables/_datatable.html.haml