shiny - 使用 rhandsontable 但不使用 dq_render_handsontable 的反应数据表
问题描述
我正在尝试构建一个 rhandsontable,但这次使用 dq_render_handsontable,因为它提供了额外的功能来放置漂亮的过滤器和分页。在我的应用程序中,我根据选择器输入对数据进行了两次过滤,这将创建两个反应性数据帧... filter_tbl_1() 在第一次拟合之后和 filter_tbl_2() 在第二次之后。
dq_render_handsontable 函数适用于 filter_tbl_1() 数据并提供正确的过滤。但是使用 filter_tbl_2() 会引发错误。我的猜测是它无法识别 filter_tbl_2()。不仅如此,错误中没有显示任何信息。如果有人可以提供帮助将不胜感激
最小可重现代码:
library(dqshiny)
library(rhandsontable)
library(tibble)
library(dplyr)
ui <- fluidPage(
column(
width = 4,
pickerInput(inputId = "carb_input",
label = "Pick carb",
choices = mtcars %>% pull(carb) %>% unique(),
selected = mtcars %>% pull(carb) %>% unique(),
multiple = TRUE,
options = pickerOptions(
actionsBox = TRUE,
liveSearch = TRUE,
size = 10
)),
pickerInput(inputId = "gear_input",
label = "Pick Gear",
choices = NULL,
multiple = TRUE,
options = pickerOptions(
actionsBox = TRUE,
liveSearch = TRUE,
size = 10
))
),
column(
width = 8,
dq_handsontable_output("review_table", 8L),
rHandsontableOutput("test")
)
)
server <- function(input,output,session){
filter_tbl_1 <- reactive({
mtcars %>% rowid_to_column() %>% filter(carb %in% input$carb_input)
})
observeEvent(filter_tbl_1(),{
choices <- filter_tbl_1() %>% pull(gear) %>% unique()
updatePickerInput(session, "gear_input", choices = choices, selected = choices)
})
filter_tbl_2 <- reactive({
req(input$gear_input)
filter_tbl_1() %>% filter(gear %in% input$gear_input)
})
dq_render_handsontable("review_table",
data = reactive(filter_tbl_1()))
output$test <- renderRHandsontable(rhandsontable(filter_tbl_2()))
}
shinyApp(ui,server)
在dq_render_handsontable("review_table", data = reactive(filter_tbl_1()))行中,如果将filter_tbl_1()替换为filter_tbl_2(),您将看到错误。
解决方案
推荐阅读
- dialogflow-es - DialogFlow V2 文本查询配额
- listview - 如何为选定的 ListItem onTap 着色
- javascript - window.location.href 未在 Edge 中显示内容
- java - 缺少 Java Struts 2.5.17 LocalizedTextUtil 类
- android - Android,Xamarin:无法通过 Singleton 写入应用程序首选项
- javascript - Javascript 时间选择器范围更新
- postgresql - node-postgres:多查询是原子的?
- javascript - 如何使 Div 中的 XPath 搜索正常工作?
- python - 使用一对一字段搜索查询集
- java - 如何从随机文件夹中获取随机文件