pager: Pagination and Pager Module

Description Usage Arguments Functions References Examples

View source: R/pager.R

Description

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.

Usage

1
2
3
4
5
6
7
8
pager(id, n_items, page_break = 20)

paginationUI(id, width = 6, ..., offset = 3)

pagerUI(id, label_prev = "Previous", label_next = "Next",
  centered = TRUE, class = NULL)

pagerDemo(display.mode = c("showcase", "normal", "auto"))

Arguments

id

The shared id of the pagerUI() and the pager() module

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 TRUE, the buttons are centered together, otherwise they are separated and spread to the left and right edges of their container.

class

Additional classes applied to the <nav> container.

display.mode

The mode in which to display the application. If set to the value "showcase", shows application code and metadata from a DESCRIPTION file in the application directory alongside the application. If set to "normal", displays the application normally. Defaults to "auto", which displays the application in the mode given in its DESCRIPTION file, if any.

Functions

References

https://getbootstrap.com/docs/3.3/components/#pagination

Examples

 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)
}

gadenbuie/shinyThings documentation built on Nov. 24, 2019, 6:56 p.m.