rstudio / DT

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

Apply column formats to slider labels #1119

Closed mikmart closed 5 months ago

mikmart commented 5 months ago

Fixes #247.

The format* functions append new columnDefs entries with customized renderer functions to apply column formatting. The idea in this PR is to fetch those same renderer functions to apply to filter slider labels.

DT::datatable(
  tibble::tibble(
    goal_completion = round(runif(10), 2),
    bonus = goal_completion * 15:24 * 1000,
    payday = Sys.Date() + 1:10
  ),
  filter = "top"
) |>
  DT::formatPercentage(1) |>
  DT::formatCurrency(2) |>
  DT::formatDate(3)

rstudio_q1oywttPsw

mikmart commented 5 months ago

Thank you for the kind words!

I think with these changes the previously special-cased date formatting can also be simplified. I'm planning to have a stab at refactoring that in another PR.