renderDataTable单行选择无效

时间:2017-04-03 13:13:07

标签: r datatables shiny dt

我正在使用API​​在数据表中尝试CRUD操作。对于编辑部分,一旦特定行被更新,renderDataTable 单行选择不能基于observeEvent工作。令人惊讶的是,对于 selection =“none” renderDataTable Works。期待着解决这个问题。

这是server.R中代码的一部分:

****编辑按钮和ObserveEvent:****

output$EditButton = renderUI({
row_count <- input$dataTable_rows_selected
if (length(row_count)!= 0) {
tags$div(
  actionButton("Edit", "",icon("edit"),style="color:rgb(57,156,8);border-   color:rgb(255,255,255)"),
  bsTooltip("Edit","Edit",trigger = "hover"),

  tags$b(bsModal("edit_final11","Edit Data","Edit",size="small",
                 tags$div(
                   textInput("attribute_edit11","Attribute(*)",value=info_data11[row_count,1]),
                   textInput("value_edit11","Value(*)",value=info_data11[row_count,2]),
                   textInput("unit_edit11","Unit(optional)",value=info_data11[row_count,3]),
                   actionButton("Edit_AB","OK")
                 )))
)
}
})

observeEvent(input$Edit_AB,{

toggleModal(session, "edit_final11", toggle = "close")

row_count <- input$table2_rows_selected

if(exists("movingpath_home")){
responseData2_home<-iListImage(HOST,PORT,USERNAME,PASSWORD,ZONE,movingpath_home)
}
else{
responseData2_home<-iListImage(HOST,PORT,USERNAME,PASSWORD,ZONE,homePath)
}

responseDataFilter2_home<-responseData2_home
displayableData<-as.data.frame(responseDataFilter2_home, stringAsFactors =     FALSE, row.names = NULL)
ObjectName <- as.character(displayableData[row_count,1])
ObjectPath <- as.character(responseData2_home[row_count,5])

dataPath <- paste(ObjectPath,"/",ObjectName,sep = "")

data_row_count <- input$dataTable_rows_selected

source("updateSpecificdata.R")
res_edit<-   updateSpecificdata(dataPath,info_data11[data_row_count,1],info_data11[data_row_count,2],info_data11[data_row_count,3],input$attribute_edit11,input$value_edit11,input$unit_edit11)
session$sendCustomMessage(type = 'alertmessage',message =res_edit)

info_data11<<-iListdata(dataPath)

if(class(info_data11)=="data.frame"){
output$dataTable<-DT::renderDataTable({

  responseDataFilter<-info_data11
  displayableData<-as.data.frame(responseDataFilter, stringsAsFactors = FALSE, row.names = NULL)
},server = TRUE,selection = "single",

escape=FALSE,options=list(paging=FALSE,searching = TRUE,ordering=FALSE,scrollY = 400,scrollCollapse=TRUE),rownames=FALSE)
}
else{
session$sendCustomMessage(type = 'alertmessage',message =info_data)

}
})

0 个答案:

没有答案