Sha256: e56f00f3bd6e3690a5b7cf68ab07ba1221da4c994f93e557c582d287b90f6c27

Contents?: true

Size: 950 Bytes

Versions: 5

Compression:

Stored size: 950 Bytes

Contents

require "datagrid/engine"
require "action_view"

module Datagrid
  module Helper

    def datagrid_format_value(report, column, asset)
      datagrid_renderer.format_value(report, column, asset)
    end

    def datagrid_table(report, *args)
      datagrid_renderer.table(report, *args)
    end

    def datagrid_header(grid, options = {})
      datagrid_renderer.header(grid, options)
    end

    def datagrid_rows(report, assets, options = {})
      datagrid_renderer.rows(report, assets, options)
    end

    def datagrid_order_for(grid, column)
      datagrid_renderer.order_for(grid, column)
    end

    protected

    def datagrid_renderer
      Renderer.for(self)
    end

    def datagrid_column_classes(grid, column)
        order_class = grid.order == column.name ? ["ordered", grid.descending ? "desc" : "asc"] : nil
      [column.name, order_class].compact.join(" ")
    end
  end
end
ActionView::Base.send(:include, Datagrid::Helper)

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
datagrid-0.5.4 lib/datagrid/helper.rb
datagrid-0.5.3 lib/datagrid/helper.rb
datagrid-0.5.2 lib/datagrid/helper.rb
datagrid-0.5.1 lib/datagrid/helper.rb
datagrid-0.5.0 lib/datagrid/helper.rb