require 'datatables'
require 'daru'
df = Daru::DataFrame.new({b: [11,12,13,14,15], a: [1,2,3,4,5],
c: [11,22,33,44,55]},
order: [:a, :b, :c],
index: [:one, :two, :three, :four, :five])
DataTables.init_iruby
t = DataTables::DataTable.new(pageLength: 3)
t.to_html
t.to_html(id='table_id1')
table_opts = {
class: "display",
cellspacing: "0",
width: "100%"
}
options ={
table_options: table_opts
}
t.to_html(id='table_id1', options)
# id is automatically added into table_options
options
options[:table_options][:table_html] = df.to_html_thead + df.to_html_tbody
html_code = t.to_html(id='table_id1', options)
# Fix me: It is showing normal html code. That means DataTables js and css is not working or loading.
IRuby.html html_code
html_code.html_safe
# Fix me: It is showing normal html code. That means DataTables js and css is not working or loading.
IRuby.html html_code
t_opts = {
data: [[1,1,1],
[1,2,3],
[11,12,13],
[1,2,3],
[11,12,13],
[1,2,3],
[11,12,13]
],
pageLength: 4
}
table_from_array = DataTables::DataTable.new(t_opts)
table_opts = {
class: "display",
cellspacing: "0",
width: "50%",
table_html: "
"
}
options = {
table_options: table_opts
}
html_code_array_sorted = table_from_array.to_html(id='table_id4', options)
IRuby.html html_code_array_sorted
IRuby.display(IRuby.javascript(table_from_array.to_html('id1')))
IRuby.html(table_from_array.to_html(id='table_id4', options))
table_html = "
Num1
Num2
Num3
Num1 | Num2 | Num3 |
---|