ThomasSiegmund / D3TableFilter

A table widget based on Max Guglielmi's "HTML Table Filter Generator" and D3.js
Other
65 stars 17 forks source link

does not work in `static` mode #1

Closed timelyportfolio closed 7 years ago

timelyportfolio commented 9 years ago

Maybe I'm confused, but I thought d3tf should work in both static and shiny modes. static currently does not work since jQuery is not available in this line.

I did confirm that static sort of works when the jQuery depedency is added. Here is an example. Of course, you'll want to add jQuery in the yaml if you want to pursue this.

library(D3TableFilter)
library(htmltools)
library(magrittr)

tagList(d3tf(mtcars,
     tableProps = tableProps,
     showRowNames = TRUE,
     tableStyle = "table table-bordered"
)) %>%
  attachDependencies(
    htmlDependency(
      name = "jquery"
      ,version = "1.11.2"
      ,src = c(href = "http://code.jquery.com/")
        ,script = "jquery-1.11.2.min.js"
    )
  ) %>%
  htmltools::html_print()

Please sort of disregard if static is not an option. However, I would strongly encourage that a widget work in all contexts.

ThomasSiegmund commented 9 years ago

Dear Kenton,

thanks for all your nice comments, very helpful indeed.

I agree that static mode would be good to have. Actually I could make good use of self contained html tables in my own work .

I've included jquery as first step, but there are at least two problems:

I will look into this soon.

Thanks again

Thomas

On Sun, Mar 1, 2015 at 10:47 PM, timelyportfolio notifications@github.com wrote:

Maybe I'm confused, but I thought d3tf should work in both static and shiny modes. static currently does not work since jQuery is not available in this line https://github.com/ThomasSiegmund/D3TableFilter/blob/master/inst/htmlwidgets/D3TableFilter.js#L15 .

I did confirm that static sort of works when the jQuery depedency is added. Here is an example.

library(D3TableFilter) library(htmltools) library(magrittr)

tagList(d3tf(mtcars, tableProps = tableProps, showRowNames = TRUE, tableStyle = "table table-bordered" )) %>% attachDependencies( htmlDependency( name = "jquery" ,version = "1.11.2" ,src = c(href = "http://code.jquery.com/") ,script = "jquery-1.11.2.min.js" ) ) %>% htmltools::html_print()

Reply to this email directly or view it on GitHub https://github.com/ThomasSiegmund/D3TableFilter/issues/1.

ThomasSiegmund commented 9 years ago

Please check latest version. Many things in static mode seem to work now.

saveWidget(... selfcontained = TRUE) fails for me with pandoc errors in this example:


library(magrittr)
library(htmlwidgets)
library(D3TableFilter)

tableProps <- list(
  btn_reset = TRUE,
  sort = TRUE,
  sort_config = list(
    # alphabetic sorting for the row names column, numeric for all other columns
    sort_types = c("String", rep("Number", ncol(mtcars)))
  )
);

mtcars %>% d3tf(tableProps = tableProps,
                        showRowNames = TRUE,
                        tableStyle = "table table-bordered") %>% 
  saveWidget(file = "test.html", selfcontained = TRUE)
ThomasSiegmund commented 9 years ago

Now D3 related functions work in static mode too, including D3 magic when editing a table. There is a demo script in examples: staticTableWithD3AndTableFilter.R