library(shiny)
library(DT)
library(reactable)
ui <- {
fluidPage(
fluidRow(
div(reactableOutput("atlas_cohort_tbl"),style = "font-size:80%")
)
)
}
server <- function(input, output, session) {
output$atlas_cohort_tbl <- renderReactable({
df <- mtcars[1:5,1:5]
reactable(df,selection = "single",
details = function(index) {
cat(paste("Ran for ", index, "\n"))
# run complex algorithm at real time
paste("Details for row:", index)},
onClick = c("expand"),
# Give rows a pointer cursor to indicate that they're clickable
rowStyle = list(cursor = "pointer"))
})
}
shinyApp(ui, server)
字符串
我有一个带有reactable表的简单应用程序。我想做的是,当一行被单击时,用详细信息展开该行,但仅当该行被单击时才运行详细信息。当前,详细信息函数对所有行都运行。我只想为被单击的行运行,因为该表将有超过2000行,详细信息函数将是复杂和耗时的。我相信这可以用我不太熟悉的JS来完成。
另外,我喜欢datatable的行选择,而不是reactable。您会看到整行都高亮显示,我可以轻松地提取行选择。
这个工作流可以用datatable完成吗?基本上单击该行,该行将扩展详细信息,这些详细信息是使用该函数实时计算的。
1条答案
按热度按时间r9f1avp51#
我不知道你想要什么。是否要使用
groupBy
?是否要在行详细信息中呈现函数生成的内容?此应用程序是否回答了您的问题?
字符串