I'm encountering an issue with accessing radio button values within a data table in Shiny when using the paging = TRUE
option. I've tried implementing code based on this example: Radio Buttons in DT
The functionality works fine for me on the initial page, but I'm unable to retrieve input values from other pages.
Below is the sample code being used:
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 = FALSE,
options = list(dom = 'Bfrtip',
paging = TRUE,
pageLength = 6,
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]]))
})
}
)
In my scenario, I am having difficulty retrieving the radio button values for the months of 'Jul' to 'Dec'. My table consists of over 100 rows and I require access to input values across multiple pages.