You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to create a renderUI() function that produces a UI that includes an editable table.
When I use renderTable() it is successful.
When I use renderHotable() it throws an error.
I printed out the functions that both render functions return.
They differ at least in the attributes / classes of the function.
Perhaps this is the source of the problem.
Below I give some sample code and output for both scenarios.
I'm trying to create a renderUI() function that produces a UI that includes an editable table.
When I use renderTable() it is successful.
When I use renderHotable() it throws an error.
I printed out the functions that both render functions return.
They differ at least in the attributes / classes of the function.
Perhaps this is the source of the problem.
Below I give some sample code and output for both scenarios.
regards
Desmond
renderHotable version
throws an error and produces the following
VALUE: dfPed = 'data.frame': 2 obs. of 2 variables:
$ a: int 1 2
$ b: int 3 4
VALUE: fnRender = function ()
function ()
{
df <- func()
if (is.null(df)) {
return()
}
if (nrow(df) == 0) {
return()
}
json <- NULL
json$colHeaders <- colnames(df)
columns <- NULL
types <- sapply(df, typeof)
l <- length(types)
readOnly <- rep(readOnly, length.out = l)
for (i in 1:l) {
if (i == 1) {
columns[[i]] <- list(readOnly = readOnly[i])
}
else if (types[i] == "double") {
columns[[i]] <- list(type = "numeric", format = "0,0.00",
readOnly = readOnly[i])
}
else if (types[i] == "logical") {
columns[[i]] <- list(type = "checkbox", readOnly = readOnly[i])
}
else {
columns[[i]] <- list(readOnly = readOnly[i])
}
}
json$columns <- columns
json$data <- df
json
}
<environment: 0x00000000250e8008>
VALUE: LL = List of 4
$ :Classes 'html', 'character' atomic [1:1] Pedigree Diagram
.. ..- attr(, "html")= logi TRUE
$ :function (shinysession, name, ...)
..- attr(, "class")= chr [1:2] "shiny.render.function" "function"
..- attr(, "outputFunc")=function (outputId, width = "100%", height = "400px", click = NULL, dblclick = NULL, hover = NULL, hoverDelay = NULL, hoverDelayType = NULL, brush = NULL, clickId = NULL, hoverId = NULL,
inline = FALSE)
$ :Classes 'html', 'character' atomic [1:1]
.. ..- attr(, "html")= logi TRUE
$ :function ()
REPORT: renderUI() END
Error in as.character(x) :
cannot coerce type 'closure' to vector of type 'character'
it produces the following trace of the error
Enter a frame number, or 0 to exit
1: runApp(file.path("..", sAppDir))
2: shinyCallingHandlers(while (!.globals$stopped) {
serviceApp()
Sys.sleep(0.001)
})
3: withCallingHandlers(expr, error = function(e) {
handle <- getOption("shiny.error")
if (is.function(handle))
handle()
})
4: Sys.sleep(0.001)
whereas
renderTable version
runs cleanly and produces the following
VALUE: dfPed = 'data.frame': 2 obs. of 2 variables:
$ a: int 1 2
$ b: int 3 4
VALUE: fnRender = function ()
function ()
{
classNames <- getOption("shiny.table.class") %OR% "data table table-bordered table-condensed"
data <- func()
if (is.null(data) || identical(data, data.frame()))
return("")
return(paste(utils::capture.output(print(xtable(data, ...),
type = "html", html.table.attributes = paste("class="",
htmlEscape(classNames, TRUE), """, sep = ""), ...)),
collapse = "\n"))
}
<environment: 0x00000000219b3fa0>
attr(,"class")
[1] "shiny.render.function" "function"
attr(,"outputFunc")
function (outputId)
{
div(id = outputId, class = "shiny-html-output")
}
<environment: namespace:shiny>
VALUE: LL = List of 4
$ :Classes 'html', 'character' atomic [1:1] Pedigree Diagram
.. ..- attr(, "html")= logi TRUE
$ :function (shinysession, name, ...)
..- attr(, "class")= chr [1:2] "shiny.render.function" "function"
..- attr(, "outputFunc")=function (outputId, width = "100%", height = "400px", click = NULL, dblclick = NULL, hover = NULL, hoverDelay = NULL, hoverDelayType = NULL, brush = NULL, clickId = NULL, hoverId = NULL,
inline = FALSE)
$ :Classes 'html', 'character' atomic [1:1]
.. ..- attr(, "html")= logi TRUE
$ :function ()
..- attr(, "class")= chr [1:2] "shiny.render.function" "function"
..- attr(, "outputFunc")=function (outputId)
REPORT: renderUI() END
The text was updated successfully, but these errors were encountered: