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

dq_render_handsontable not working when put in module #23

Open
FrankSchiro opened this issue Dec 31, 2020 · 0 comments
Open

dq_render_handsontable not working when put in module #23

FrankSchiro opened this issue Dec 31, 2020 · 0 comments

Comments

@FrankSchiro
Copy link

FrankSchiro commented Dec 31, 2020

I'm having trouble getting a shiny module to display the dqshiny handsontable. I think it is a namespace issue, but really, I have no idea. The table data does not display in the module example below. I also include an example of the code working when not using modules.

Nonworking code example using module:

library(shiny)
library(rhandsontable)
library(dqshiny)

# module UI ->
myModuleUI <- function(id) {
  ns <- NS(id)
  tagList(
    fluidRow(
        dq_handsontable_output(ns("dataTable"))
    )
  )
}
# module server ->
myModule <- function(input, output, session, df) {
    dq_render_handsontable("dataTable", df)
}
# Use the module in an application
ui <- fluidPage(
  myModuleUI("myModule1")
)
server <- function(input, output, session) {
    df = data.frame(
        company = c('a', 'b', 'c', 'd'),
        bond = c(0.2, 1, 0.3, 0),
        equity = c(0.7, 0, 0.5, 1),
        cash = c(0.1, 0, 0.2, 0),
        stringsAsFactors = FALSE
    )
  callModule(myModule, "myModule1",  df = df)
}
shinyApp(ui, server)

The code below works without using modules:

shinyApp(
  ui = fluidPage(
    dq_handsontable_output("dataTable")
  ),
  server = function(input, output, session) {
    df = data.frame(
        company = c('a', 'b', 'c', 'd'),
        bond = c(0.2, 1, 0.3, 0),
        equity = c(0.7, 0, 0.5, 1),
        cash = c(0.1, 0, 0.2, 0),
        stringsAsFactors = FALSE
    )
    dq_render_handsontable("dataTable", df)
  }
)
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

1 participant