jimhester / knitrBootstrap

A framework to create bootstrap styled HTML reports from knitr Rmarkdown.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rendering datatable() from DT package fails

jkraut opened this issue · comments

When using the DT package in conjunction with knitrBoostrap, the datatable fails to render in the HTML but the underlying components exist.

I don't have a lot of experience with .js or HTML, but there are no .js errors when I inspect the element in Chrome. After digging around the raw HTML a bit, it looks like the call to render the table is being suppressed or left out. I've tried using the solution found here, but it doesn't solve the issue.

In the simple example below the datatable renders w/o knitrBootstrap but fails to render in the knitrBootrap styled document:

library(DT)
datatable(iris)

I am able to workaround this by using kable, setting an id and then utilizing javascript outside of the markdown chunk to render the table, but it's not ideal:

kable(value_test, "html", table.attr = "id=\"test_table\"")

followed by:

<script type="text/javascript"> $(document).ready(function() { $('#test_table').DataTable(); } );

I think that using kable() + js is the way go here. At least for now.


The installation instructions for DT are available at http://rstudio.github.io/DT/ and I can see that it does work with HTML format out of the box without the kable() + js part.