Skip to content

Instantly share code, notes, and snippets.

@StevenMMortimer
Last active August 29, 2015 14:21
Show Gist options
  • Save StevenMMortimer/a0619adbe80fcf5cbacb to your computer and use it in GitHub Desktop.
Save StevenMMortimer/a0619adbe80fcf5cbacb to your computer and use it in GitHub Desktop.
library(shiny) #shiny_0.11.1.9005
library(DT) #DT_0.0.41
# create sample table
data <- matrix(1:200000, ncol = 4, dimnames=list(NULL, c("Row Index", "V1", "V2", "V3")))
ui = shinyUI(
fluidPage(
fluidRow(
column(1),
column(4,
h4('length(input$tbl_rows_all) says:'),
textOutput("text1"),
hr(),
h4('And their row indices are:'),
textOutput("text1b")
),
column(6,
DT::dataTableOutput('tbl')
),
column(1)
)
)
)
server = function(input, output, session) {
action = dataTableAjax(session, data)
# render the widget
widget = DT::datatable(
data, server=TRUE,
options = list(
ajax = list(url = action)
),
filter = 'bottom'
)
output$tbl = DT::renderDataTable(widget)
output$text1 <- renderText({
paste(length(input$tbl_rows_all), "Total Rows in Table")
})
output$text1b <- renderText({
paste(paste(input$tbl_rows_current, collapse=", "))
})
}
shinyApp(ui = ui, server = server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment