Problem with DT SearchPanes : only first 10 unique values appear in the panes

Viewed 203

I am trying to use the new SearchPanes and Buttons features from the DT package for filtering/selecting rows of a (rather large) datatable within a shiny app, along with the Scroller extension but I have problems with the searchpanes: when using both SearchPanes and Scroller only the first 10 unique values appear in the searchpanes.

Minimal example with the dataset gapminder form package gapminder:

library(shiny)
library(DT)
library(magrittr)
library(gapminder)

shinyApp(
  ui = fluidPage(
    dataTableOutput('tbl')
  ),

  server = function(input, output) {
    output$tbl = renderDataTable(server=FALSE, {
      datatable(gapminder,
        rownames = FALSE,
        colnames = c("Country", "Continent", "Year",
                     "Life Exp", "Population", "GDP per capita"),
        extensions = c("SearchPanes", "Select", "Buttons", "Scroller"),
        options = list(
          dom = "Brtip",
          buttons = list("searchPanes"),
          language = list(searchPanes = list(collapse = "Filter Rows")),
          scrollY = 500,
          scroller = TRUE,
          columnDefs = list(
            list(searchPanes = list(show = FALSE), targets = c(3:5)),
            list(searchPanes = list(controls = FALSE), targets = 0:2),
            list(className = "dt-center", targets = 0:5)
          )
        ),
        selection="none"
      ) %>% 
      formatRound(4, 1) %>% 
      formatRound(5, 0) %>% 
      formatCurrency(6, digits = 0)
    })
  }
)

In the searchpanes of this example app the filtering choices for "Country" only go from "Afghanistan" to "Belgium", while there are much more countries in the dataset:

screenshot of SearchPanes issue in shiny app

However if I don't use the Scroller extension, the problem disappears:

shinyApp(
  ui = fluidPage(
    dataTableOutput('tbl')
  ),

  server = function(input, output) {
    output$tbl = renderDataTable(server=FALSE, {
      datatable(gapminder,
        rownames = FALSE,
        colnames = c("Country", "Continent", "Year",
                     "Life Exp", "Population", "GDP per capita"),
        extensions = c("SearchPanes", "Select", "Buttons"),
        options = list(
          dom = "Brtip",
          buttons = list("searchPanes"),
          language = list(searchPanes = list(collapse = "Filter Rows")),
          columnDefs = list(
            list(searchPanes = list(show = FALSE), targets = c(3:5)),
            list(searchPanes = list(controls = FALSE), targets = 0:2),
            list(className = "dt-center", targets = 0:5)
          )
        ),
        selection="none"
      ) %>% 
      formatRound(4, 1) %>% 
      formatRound(5, 0) %>% 
      formatCurrency(6, digits = 0)
    })
  }
)

SearchPanes issue disappears when Scroller isn't used

I would really like to use the Scroller extension and the SearchPanes extension together. Anyone knows about a solution for this issue ?

Jonas

0 Answers
Related