r - R Shiny - 无法检索在 DT 表中创建的输入控件的值
问题描述
我按照 DT 官方页面中的这个示例在 DT 表中创建输入控件。我创建了类似的东西,但我还需要一个可编辑的表格。因此,我需要设置(server = TRUE
在需要的renderDT
RTFM 之后实现)。所以现在我尝试按照这个在 DT 表中呈现复选框输入的示例,但使用. 问题是现在我无法在服务器端获取输入控件的值,这在. 谁能告诉我如何在此设置中检索服务器端的控制值。reloadData
server = TRUE
server = TRUE
server = FALSE
library(shiny)
library(DT)
shinyApp(
ui = fluidPage(
title = 'Radio buttons in a table',
DT::dataTableOutput('foo'),
verbatimTextOutput('sel')
),
server = function(input, output, session) {
m = matrix(
as.character(1:5), nrow = 12, ncol = 5, byrow = TRUE,
dimnames = list(month.abb, LETTERS[1:5])
)
for (i in seq_len(nrow(m))) {
m[i, ] = sprintf(
'<input type="radio" name="%s" value="%s"/>',
month.abb[i], m[i, ]
)
}
m
output$foo = DT::renderDataTable(
m, escape = FALSE, selection = 'none', server = TRUE,
options = list(dom = 't', paging = FALSE, ordering = FALSE),
callback = JS("table.rows().every(function(i, tab, row) {
var $this = $(this.node());
$this.attr('id', this.data()[0]);
$this.addClass('shiny-input-radiogroup');
});
Shiny.unbindAll(table.table().node());
Shiny.bindAll(table.table().node());")
)
output$sel = renderPrint({
str(sapply(month.abb, function(i) input[[i]]))
})
}
)
解决方案
推荐阅读
- python - 选择带有 selenium python 问题的元素
- r - 调用编译后的 R 函数
- c++ - str.length() 如何计算字符串长度()?
- database - 在 Tableau 中比较两个数据集
- c++ - stoi, stol, stoll 将最大大小数据类型的字符串转换为 int 数据类型的限制
- javascript - 计算 x,y 坐标,考虑旋转
- javascript - 组件未使用“useEffect”挂钩在 React 中重新渲染
- angular - **build --prod** 时延迟加载不起作用
- winforms - Windows 集成身份验证 Azure AD 和 WinForms
- php - 使用ajax codeigniter的文件上传总是NULL