Class: Daru::View::DataTable

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::TagHelper, Display, JsHelpers
Defined in:
lib/daru/data_tables/data_table.rb,
lib/daru/data_tables/display/display.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from JsHelpers

#draw_ajax_option, #draw_js, #draw_js_iruby, #extract_data_array, #set_callback_ajax

Methods included from ParamHelpers

#js_parameters, #typecast

Methods included from Display

#show_in_iruby, #show_script, #to_html, #to_js

Constructor Details

#initialize(data = [], options = {}) ⇒ Object

Returns Initializes the Daru::DataTables::DataTable object.

Examples:

vec = Daru::Vector.new([1, 2, 3], name: :a)
opts = {searching: false}
table = Daru::DataTables::DataTable.new(vec, opts)

Parameters:

  • data (Array, Daru::DataFrame, Daru::Vector) (defaults to: [])

    The data provided by the user to generate the datatable

  • options (Hash) (defaults to: {})

    Various options provided by the user to incorporate in datatable



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/daru/data_tables/data_table.rb', line 15

def initialize(data=[], options={})
  @element_id = options.delete(:element_id) unless options[:element_id].nil?
  @html_options = options.delete(:html_options) unless options[:html_options].nil?
  @html_options ||= default_html_options
  @data = data
  @options = options
  @options[:data] = to_data_array(data)
  row_number = 0
  @options[:data].each do |array|
    array.unshift(row_number)
    row_number += 1
  end
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



5
6
7
# File 'lib/daru/data_tables/data_table.rb', line 5

def data
  @data
end

#element_idObject

Returns the value of attribute element_id.



5
6
7
# File 'lib/daru/data_tables/data_table.rb', line 5

def element_id
  @element_id
end

#html_optionsObject

Returns the value of attribute html_options.



5
6
7
# File 'lib/daru/data_tables/data_table.rb', line 5

def html_options
  @html_options
end

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/daru/data_tables/data_table.rb', line 5

def options
  @options
end