Skip to content

error: There is already an input handler for type: htable #22

@cloudarch

Description

@cloudarch

Hi ,

I am hitting the error below when I try to run the example-1 app from my local.

Error : .onLoad failed in loadNamespace() for 'shinyTable', details:
call: shiny::registerInputHandler("htable", function(val, shinysession,
error: There is already an input handler for type: htable
Error : package or namespace load failed for ‘shinyTable’

Below is the source code.

ibrary(shiny)
library(shinyTable)

' Define UI for application that demonstrates a simple Handsontable

' @author Jeff Allen \email{jeff@@trestletech.com}

shinyUI(pageWithSidebar(

Application title

headerPanel("Simple Shiny Table!"),

sidebarPanel(
#sliderInput("slider", "Number of rows:", 1, 26, 5),
#HTML("


"),
helpText(HTML("A simple table with validation. The first column must be a number and if it's >= 100, it will be assigned the value of 99. Other columns can be anything.
Additionally, the second column has server-side styling applied and will highlight as 'invalid' any value >= 100, and will 'warn' on values >= 50.

Created using <a href = "http://github.com/trestletech/shinyTable\">shinyTable."))
),

Show the simple table

mainPanel(
htable("tbl", colHeaders="provided")
)
))

library(shiny)
library(shinyTable)

' Define server logic required to generate simple table

' @author Jeff Allen \email{jeff@@trestletech.com}

shinyServer(function(input, output, session) {
cachedTbl <- NULL

validate <- function(tbl){
updateTableStyle(session, "tbl", "valid",
which(as.numeric(tbl$num2) < 50), 2)
updateTableStyle(session, "tbl", "warning",
which(as.numeric(tbl$num2) >= 50 &
as.numeric(tbl$num2) < 100), 2)
updateTableStyle(session, "tbl", "invalid",
which(as.numeric(tbl$num2) >= 100), 2)
}

output$tbl <- renderHtable({
if (is.null(input$tbl)){
rows <- 5
# Seed the element with some data initially
tbl <- data.frame(list(num1=1:rows,
num2=(1:rows)*20,
letter=LETTERS[1:(rows)]))
rownames(tbl) <- LETTERS[2:(rows+1)]
validate(tbl)

  cachedTbl <<- tbl      
  return(tbl)
} else{
  # Updates from client. The server has been made aware and can do some
  # validation or updates here, then send back the revised table. In this
  # case, we'll filter any number >= 100 in the first column.
  tbl <- input$tbl

  # Any non-numeric data should be replaced with the cached data.
  tbl[is.na(as.integer(as.character(tbl[,1]))),1] <- 
    as.character(cachedTbl[is.na(as.integer(as.character(tbl[,1]))),1])

  validate(tbl)

  tbl[as.integer(as.character(tbl[,1])) >= 100,1] <- 99
  cachedTbl <<- tbl
  return(tbl)
}

})
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions