Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(shiny)
- library(DT)
- M<-mtcars[1:5,] %>%
- {mutate(.,names=gsub(" ","_",row.names(.)))} %>%
- mutate(.,cb=
- Map(function(x,y){
- sprintf('<input type="checkbox" name="%s" value="%s"/>',x,y)
- },
- x=names,
- y=TRUE
- )
- ) %>%
- select(mpg,cyl,names,cb)
- shinyApp(
- ui = shinyUI(fluidPage(
- titlePanel("DataTable_with_CheckBox"),
- sidebarLayout(
- sidebarPanel(
- ),
- mainPanel(
- DT::dataTableOutput('foo')
- )
- )
- )),
- server =
- shinyServer(function(input, output) {
- output$foo = DT::renderDataTable(
- M, escape = FALSE, selection = 'none', server = T,
- options = list(dom = 't', paging = FALSE, 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());")
- )
- })
- )
Add Comment
Please, Sign In to add comment