rstudio / DT

R Interface to the jQuery Plug-in DataTables
https://rstudio.github.io/DT/
Other
587 stars 184 forks source link

Add way to pass configuration to Selectize and noUiSlider widgets #1120

Closed mikmart closed 5 months ago

mikmart commented 5 months ago

Closes #1072, closes #1083.

This PR adds support to use the filter parameter in datatable() to pass configuration directly to filter widget initialization in JavaScript. This is done by specifying a $settings element in the list form of the filter parameter, which itself is a named list with $select and $slider elements for select and slider widget configuration, respectively.

Example usage:

DT::datatable(
  data.frame(
    foo = factor(LETTERS, levels = sample(LETTERS)),
    bar = rnorm(seq_along(LETTERS)) |> round(3)
  ),
  filter = list(
    position = "top",
    settings = list(
      select = list(
        sortField = list(field = "text", direction = "desc")
      ),
      slider = list(
        orientation = "vertical"
      )
    )
  )
)