Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

does not work in static mode #1

Closed
timelyportfolio opened this issue Mar 1, 2015 · 3 comments
Closed

does not work in static mode #1

timelyportfolio opened this issue Mar 1, 2015 · 3 comments

Comments

@timelyportfolio
Copy link
Contributor

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
Copy link
Owner

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:

  • TableFilter doesn't find it's css and some js files
  • I guess I have to actively disable some of the shiny related functions
    for static mode

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
#1.

@ThomasSiegmund
Copy link
Owner

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants