require 'daru/view'
Install the spreadsheet gem version ~>1.1.1 for using spreadsheet functions. Install the mechanize gem version ~>2.7.5 for using mechanize functions.
true
Daru::View.table_library = :datatables
:datatables
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])
a | b | c | |
---|---|---|---|
one | 1 | 11 | 11 |
two | 2 | 12 | 22 |
three | 3 | 13 | 33 |
four | 4 | 14 | 44 |
five | 5 | 15 | 55 |
dt_df = Daru::View::Table.new(df, pageLength: 3)
#<Daru::View::Table:0x00000003ed09b0 @data=#<Daru::DataFrame(5x3)> a b c one 1 11 11 two 2 12 22 three 3 13 33 four 4 14 44 five 5 15 55, @options={:pageLength=>3}, @adapter=Daru::View::Adapter::DatatablesAdapter, @table=#<Daru::DataTables::DataTable:0x00000003ed0960 @options={:pageLength=>3}>>
dt_df.table.to_html
"\n<script type='text/javascript'>\n \n$(document).ready(function() {\n\n $('#c729c4fa-606e-44c1-92b0-c42806ea5dc5').DataTable(\n {pageLength: 3}\n );\n\n});\n</script>\n"
table_opts = {
class: "display",
cellspacing: "0",
width: "50%",
table_html: "
<thead>
<tr>
<th>Num1 </th>
<th>Num2 </th>
<th>Num3 </th>
</tr>
</thead>"
}
options = {
table_options: table_opts
}
html_code_dt_df = dt_df.table.to_html(id='table_id4', options)
"\n<script type='text/javascript'>\n \n$(document).ready(function() {\n\n $('#table_id4').DataTable(\n {pageLength: 3}\n );\n\n});\n</script>\n<table class=\"display\" cellspacing=\"0\" width=\"50%\" id=\"table_id4\">\n <thead>\n <tr>\n <th>Num1 </th>\n <th>Num2 </th>\n <th>Num3 </th>\n </tr>\n </thead></table>"
IRuby.html html_code_dt_df
Num1 | Num2 | Num3 |
---|