Change the value from one column on selecting the dynamic input selectors from other columns

Hello , I need to some help in making the dynamic components in column Answer to update the tabledata1 columnsimage and showcase the new value that is assigned to it on every click.
#Libraries
library(shiny)
library(shinydashboard)
library(highcharter)
library(purrr)
library(dplyr)
library(shinyWidgets)
library(DT)
library(shinyBS)

tabledata1 <- data.frame(country = c("Australia","Australia","Australia","Australia","Australia"), Code =c("Rahil","Rahil","Rahil","Rahil","Rahil") ,cat = c(1,1,1,1,1))
un_sq <- unique(tabledata1$Code)
tempa <- list()

ui <- dashboardPage(
dashboardHeader(title = "Data Updation with collapsibility functionality" , disable = FALSE),
dashboardSidebar(),
dashboardBody(

fluidRow(
  box(
    title = "Table Structure", status = "primary", solidHeader = TRUE,
    collapsible = TRUE,width = 12,uiOutput("Works")
  )
)

)
)
server <- function(input,output,session){
output$Works <- renderUI({
lapply( 1:length(un_sq),function(i) {
bsCollapse(id = "collapseExample",
bsCollapsePanel(un_sq[i], dataTableOutput(paste("mytable", i , sep ="")), style = "primary")
)

}
)})


shinyValue = function(id, len) { 
  unlist(lapply(seq_len(len), function(i) { 
    value = input[[paste0(id, i)]] 
    if (is.null(value)) NA else value 
  })) 
}
Rahil = function(FUN, len, id, ...) { 
  inputs = character(len) 
  for (i in seq_len(len)) { 
    inputs[i] = as.character(FUN(paste0(id, i), label = NULL, ...)) 
  } 
  inputs 
} 

th <- function(){

 for(i in 1:nrow(tabledata1)){
    
    tempa[[i]]=data.frame(tabledata1[i,],Answer=   Rahil(radioButtons , nrow(tabledata1[i,]),paste0("radio" , i),selected ="yes" ,
                                                          choices =c("yes", "no"), inline= T),OP =  tabledata1$cat[i])
    
 }

return(do.call(rbind,tempa))

}

rea1 <- reactiveValues(df = th()
)
rea2<- reactive({rea1$df})

observeEvent(input$radio11,{

if(rea1$df$cat[1] == 1){
rea1$df$cat[1] =2
print(rea1$df$cat[1])
}else{
rea1$df$cat[1]=1
print(rea1$df$cat[1])
}
rea2()

})

output$mytable1 = DT::renderDataTable({rea2()},selection='none',server = FALSE, escape = FALSE,class = 'cell-border stripe', options = list(columnDefs = list(list(width = '600px', targets = 2),list(visible=FALSE)), ordering=F,pageLength = 10000, lengthMenu = c(5, 10, 20, 100, 1000, 10000) , dom ="t",
preDrawCallback = JS('function() {
Shiny.unbindAll(this.api().table().node()); }'),
drawCallback = JS('function() {
Shiny.bindAll(this.api().table().node()); } ')))

}

shinyApp(ui, server)

Please let me know if any one have solution to this problem in Datatables

This seems like it's a duplicate of Display Value instantly in Datatable when radio button is clicked. Is this a homework problem?

Hi Hadley,

No this is not a homework problem. It is requirement we are trying to develop. The other post also belongs to one of the developer working on this with me.

We are facing this issue since couple of days.

In that case, it's rude to post multiple times without linking between the issues, and you should follow the advice to create a minimal reprex in the previous post.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.