javascript - JS闪亮内的反应表
问题描述
我有一个需要在用户单击加号按钮时显示的表格。但是这个表是反应性的,它取决于条件。有没有办法做到这一点。我在下面尝试并没有成功。
该表在这里是被动的。所以需要在JS里面合并
library(shiny)
library(DT)
library(shinyjs)
ui <- {
fluidPage(
fluidRow(
column(6,
dataTableOutput('table1')
),
column(6,
DTOutput('table2')
)
)
)
}
server <- function(input, output, session) {
if(3 > 1){
x = 2
} else {
x = 1
}
table1 <- reactive({
tags$div(style = "background-color:#cbe6ef;padding:5em",tags$table(tags$thead(tags$tr(tags$th("Number of Reviews",x)))))
})
output$table1<-
DT::renderDataTable({
datatable(cbind(Plus = '+',iris), escape = F,
rownames = F,
selection = 'none',
plugins = 'natural',
extensions = c('Buttons','Responsive'),
callback = JS("
table.column(1).nodes().to$().css({cursor: 'pointer'});
var format = function(d) {
return '/table1/';
};
table.on('click', 'td.details-control', function() {
var td = $(this), row = table.row(td.closest('tr'));
if (row.child.isShown()) {
row.child.hide();
td.html('+');
} else {
row.child(format(row.data())).show();
td.html('−');
}
});"
))
})
}
options(shiny.launch.browser = TRUE)
shinyApp(ui, server)
解决方案
推荐阅读
- authlib - 限制令牌范围服务器端
- powerbi - 过滤更改条形图和折线图的前 25 个条目
- python - 如何在 Django 中由管理员下载更新的文件
- php - Wordpress 在页面上显示匹配分类的过滤列表
- javascript - 在 DataTable 中显示顶点图表
- glsl - 如何在glsl中绘制一个带边框的平滑圆圈?
- firebase - 从 /webConfig 接收 403
- json - REST GET 在 Future Builder 中返回无效参数
- python - 从 Pulsar 读取并使用 asyncio 加载到 Postgres
- python - 如何启用本地 infile 服务器端?