When I append a new row with dynamic inputs to shiny datatable the previous row checkbox input loses reactivity in R

When I append a new row with dynamic inputs to shiny datatable the previous row checkbox input loses reactivity in R



check for a reactivevalues element when appended to contain a checkbox input then how to reflect the current value of a checkbox rather than the first ever default selected


shinyApp(
ui = fluidPage(dataTableOutput('foo'), actionButton("save_changes","add")),
#server side computing server = function(input, output)
# Collection configuration table
# create a character vector of shinyinputs
shinyInputadd = function(FUN, len, id, labl ,...)
iter = character(len) inputs = as.character(FUN(paste0(id, len), label = labl, ...)) inputs

rowcount <- reactiveValues(cnt = 0)
output$foo <- DT::renderDataTable(
DT=bvals$data DT$ID <- NULL datatable(
DT,
escape=F,
selection = 'none',
rownames = FALSE,
options = list(
pageLength = 20,
autoWidth = FALSE,
scrollX = FALSE,
scrollY = '500px',
dom = 't',
ordering = FALSE,
preDrawCallback = JS('function()
Shiny.unbindAll(this.api().table().node());
'),
drawCallback = JS('function()
Shiny.bindAll(this.api().table().node());
')
)
)
)
bvals <- reactiveValues(
data = data.frame(
"ID" = "None",
"SELECT" = "None",
"SEGMENT" = "None",
"SCENARIO" = "None",
"REMOVE" = "None"
)[0,]
)
#when user clicks 'Add '
observeEvent(
input$save_changes,

rowcount$cnt <- rowcount$cnt + 1 n <- rowcount$cnt
#remove rows with value None
batchdt = bvals$data dt_sel_id <- data.frame(
"SELECT" = shinyInputadd(
checkboxInput,
n,
"bcheckb_",
"",
value = TRUE
),
"ID" = n
)
#Create a dataframe with one row having Delete button
dt_rem_button <- data.frame(
"REMOVE" = shinyInputadd(
actionButton,
n,
"bdelete_",
"",
align = "right",
class ="needed",
icon("minus-circle"),
style="color: #b22222; background-color: #fff ;height = 70px ;width = 70px"
)
)
dt_bind <- cbind(
dt_sel_id,
data.frame(
"SEGMENT" = 1,
"SCENARIO" = 1
),
dt_rem_button
)
#Append new row with new seqUence and the above buttons to the existing values in the collection table
bvals$data <- rbind(
bvals$data,
dt_bind
)

)

)






Welcome to Stack Overflow and thank's for your contribution! Please try to edit your question to include the essential parts of the code. Here you can read about general guidelines for good questions: How to ask a good question. Thanks!

– David
Sep 13 '18 at 21:39






Thanks for posting the code, but I'm still having trouble understanding your problem. What is it doing now? Can you restate what you want it to do?

– divibisan
Sep 14 '18 at 18:17






I am trying to add a dynamic row which then can be modified for its value but every time I do that it retains the first ever value set for the current created input element. Currently what it does is retain the value of the input element when it first creates a row

– nkaty
Sep 24 '18 at 6:29




0



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)