Description Usage Arguments Functions References Examples
A pager module to add pagination to any collection of items. Given a number of items and a page break, the pagination module returns the indexes of the items on the currently selected page.
1 2 3 4 5 6 7 8 |
id |
The shared |
n_items |
The number of items in the collection of items to be paged |
page_break |
The maximum number of items in each page |
width |
The width of the containing column |
... |
Additional elements included in the containg column, added before the pagniation buttons |
offset |
The offest of the containing column |
label_prev |
The label of the "Previous" button. |
label_next |
The label of the "Next" button". |
centered |
If |
class |
Additional classes applied to the |
display.mode |
The mode in which to display the application. If set to
the value |
paginationUI
: The user interface for the pager module. The pager is
contained in a single column in a fluidRow()
.
pagerUI
: Next/previous buttons that can be used in addition to,
or in place of paginationUI()
.
pagerDemo
: Example app demonstrating usage of the pager module.
https://getbootstrap.com/docs/3.3/components/#pagination
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | if (interactive()) {
library(shiny)
ui <- fluidPage(
titlePanel("shinyThings Pagination"),
sidebarLayout(
sidebarPanel(
width = 6,
tags$h4("paginationUI()"),
shinyThings::paginationUI("pager", width = 12, offset = 0, class = "text-center"),
tags$hr(),
sliderInput("page_break", "Page Size", min = 1, max = 6, step = 1, value = 3),
helpText(tags$code("page_break")),
tags$hr(),
tags$h4("pagerUI()"),
shinyThings::pagerUI("pager", centered = FALSE)
),
mainPanel(
width = 6,
tags$p("Page indices:"),
verbatimTextOutput("page_indices"),
tags$p(HTML("Paged output (<code>letters</code>):")),
uiOutput("paged_output")
)
)
)
server <- function(input, output) {
## page_break and n_items can be reactive or fixed values
# page_break <- 4
# n_items <- length(letters)
n_items <- reactiveVal(length(letters))
page_break <- reactive({input$page_break})
page_indices <- shinyThings::pager("pager", n_items, page_break)
output$page_indices <- renderPrint({
page_indices()
})
output$paged_output <- renderUI({
tags$ul(
lapply(letters[page_indices()], tags$li)
)
})
}
shinyApp(ui, server)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.