如何存储闪亮的dataTable对象中显示的复选框

时间:2016-11-16 12:21:57

标签: r shiny

我正在尝试构建有光泽的dataTable,它的第一列是变量名 ,它是第二个和第三个是复选框,用户在第二列中单击的复选框是我想从模型中排除的变量。 用户在第三列中单击的复选框(仅限一次)是目标变量。

我在google中找到了一个代码,所以我的代码看起来像这样:

data<-read.csv(file.choose(),header = TRUE,sep=",",quote="") #,quote=""
df.var.names <- names(data)
addCheckboxButtons <- paste0('<input type="checkbox" name="row', df.var.names, '" value="', df.var.names, '">',"")

Table<-DT::datatable(cbind(df.var.names,Exclude_variables=addCheckboxButtons,Choose_Target_variable=addCheckboxButtons),
                      options = list(orderClasses = TRUE,
                                     lengthMenu = c(5, 25, 50),
                                     pageLength = length(df.var.names), 
                                     callback = JS("function(table) {
                                                   table.on('change.dt', 'tr td input:checkbox', function() {
                                                   setTimeout(function () {
                                                   Shiny.onInputChange('rows', $(this).add('tr td input:checkbox:checked').parent().siblings(':last-child').map(function() {
                                                   return $(this).text();
                                                   }).get())
                                                   }, 10); 
                                                   });
                                    }")),escape = FALSE)

enter image description here

我的问题是: 如何单独访问第二和第三列中的复选框

代码来源: enter link description here

0 个答案:

没有答案