Integration of the absolute plugin for forcing empty values to the bottom of tables.
Requested feature
As mentioned on this page: https://rstudio.github.io/DT/plugins.html DT supports plugins and it is possible to do a feature request for integrating a plugin.
I would like to ask DT's support for the absolute plugin:
https://datatables.net/plug-ins/sorting/absolute
The use case
In our Shiny dashboard, we have a data table with a string column which has some empty values. When sorting them ascending, the empty values appear at the top. I would like that empty values always appear at the bottom, no matter the sorting is ascending or descending.
I know that there is a workaround in Shiny, by calling DT::renderDT() with a server = TRUE argument.
https://github.com/rstudio/DT/issues/568
I cannot use this workaround, since it causes the mess-up of other columns in the same table and it seems wrong to use this side effect for the functionality that I want.
Example
library(DT)
library(data.table)
datatable(data.table(iris)[1:5, Species := NA])
library(shiny)
library(DT)
ui <- fluidPage(
DT::dataTableOutput("mytable")
)
server <- function(input, output) {
output$mytable <- DT::renderDataTable(server = FALSE, {
DT::datatable(data.table(iris)[1:3, Species := NA]
)
})
}
shinyApp(ui = ui, server = server)
Thanks for this great tool!
By filing an issue to this repo, I promise that
- [x] I have fully read the issue guide at https://yihui.name/issue/.
- [x] I have provided the necessary information about my issue.
- If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
- If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included
xfun::session_info('DT'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('rstudio/DT'). - If I have posted the same issue elsewhere, I have also mentioned it in this issue.
- [x] I have learned the Github Markdown syntax, and formatted my issue correctly.
I understand that my issue may be closed if I don't fulfill my promises.
Hi,
You can use this technique: https://stackoverflow.com/a/65897972/1100107