Unecessary "Datatables warning" alert when creating a DT with new data and same number of columns
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, r
Research direction
Start with the reproducible Shiny app, especially the DTOutput() inside renderUI() and the renderDT()/datatable() sequence after hiding and showing the table. Reproduce the warning, then trace the DataTables alert behavior and verify that the unnecessary warning is removed without suppressing legitimate alerts.
Written by the indexing model from the issue text.
Description
I'm writing an app that creates certain reports at the click of a button. When a new report has the same number of columns as the previous one, DT throws an alert about how column name from old data is not present in new data, that needs to be clicked through. After that, it creates the correct table without issue! This obviously makes for poor UX since it seems something has gone wrong when, in fact, everything went OK.
I'm pretty sure the issue is that the DTOutput() function is a part of a renderUI() call. It doesn't seem likely I can move away from this since I need to make some checks before displaying or hiding the table. Here is a simplified version as a reproducible example:
library(shiny)
library(DT)
ui <- fluidPage(
actionButton("change_col", "Change column names"),
actionButton("hide_table", "Hide/Show table"),
uiOutput("custom_ui")
)
server <- function(input, output, session) {
output$custom_ui <- renderUI({
# this req() simulates that my app needs to check some reactive values to
# determine whether to show or hide the table
req(input$change_col)
# The UI programatically decides whether to show the table.
if (input$hide_table %% 2 == 1) return(h2("NO DATA"))
DT::DTOutput("my_table")
})
output$my_table <- renderDT({
req(input$change_col)
my_data <- iris
# the number of columns is always the same,
# but the column names differ each run
new_colnames <- paste(colnames(iris)[1:5],
rnorm(5)
)
colnames(my_data)[1:5] <- new_colnames
DT::datatable(my_data,
# HTML ne renderaj kao string nego stvarni HTML
escape = F,
selection = "none",
rownames = FALSE,
options = list(
dom = 'tp',
ordering = F,
language = list(zeroRecords = "Nema podataka za prikaz",
paginate = list('next' = "Sljedeća",
'previous' = "Prethodna")
),
scrollX = TRUE,
searching = F)
)
})
}
shinyApp(ui, server)
To reproduce, click on Change column names, Click on Hide/Show twice, and then Change column names again.
Do you have any suggestions as how to avoid this alert?
One solution I've found is to add a callback that disables DT alerts (adding callback = DT::JS("$.fn.dataTable.ext.errMode = 'none';") to the datatable() call). I'm not happy with that since if there were any legitimate alerts, this would disable them too.
- Dominant language
- JavaScript
- Stars
- 621
- Forks
- 177
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rstudio/DT
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
-
Excel like filteringOpen
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
Similar issues
-
[workshop-sim] Improve: Provide a concrete example and activity checks in agentic intro (step 5)Openfeedback simulation workshop
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
githubnext/gh-aw-workshop#5715 ·
Maintainers usually reply within 1 day
-
[prefer-expect-resolves] autofix leaves a stray ")" when the awaited expression is parenthesizedOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
jest-community/eslint-plugin-jest#2052 ·
-
check:passed feeds:add
Difficulty 1/5 Under an hour Newbie friendliness 66/100
-
Wallet functions throws TypeError when the wallet has no account IDPossibly taken @Medhansh-741 claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
hiero-ledger/hiero-sdk-js#4781 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100