DataTables Filename Incrementation Bug When Displaying 10 Rows in Shiny Applications

Open
#1,076 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, r
Domain
frontend, web-dev

Research direction

Start by reproducing the issue with the provided Shiny example and the DataTables Buttons CSV export, comparing downloads with exactly 10 displayed rows against other page lengths. Trace the filename-generation path used by the CSV button and confirm that the fix preserves incrementing without overwriting geo_table.csv.

Written by the indexing model from the issue text.

Description

I want to report a possible bug encountered in the DataTables extension for Shiny applications related to file name incrementation during the download of data tables.

The issue arises when using the 'Buttons' extension in DataTables to export table data. The filename incrementation behaves unexpectedly when exactly 10 rows are displayed in the data table, given the total number of rows in the data is equal to or more than 10. In such cases, the filename does not increment as expected upon download; instead, it overwrites the existing file.

However, when more or less than 10 rows are displayed in the data table, the filename increments correctly upon each download.

Here's a simplified example of the code I'm using:

output$geo_table <- DT::renderDataTable({
req(variables_geo$geo)
DT::datatable(variables_geo$geo,
rownames = FALSE,
extensions = 'Buttons',
options = list(
dom = 'Bfrtlip',
deferRender = TRUE,
lengthMenu = c(5, 10, 25, 50, 100, 1000, 10000),
buttons = list(
'colvis',
'copy',
list(
extend = 'csv',
filename = 'geo_table'
),
list(
extend = 'excel',
filename = 'geo_table'
),
list(
extend = 'pdf',
filename = 'geo_table'
),
'print'
)
)
)
})

When "Show 10 entries" selected and try to download .csv file, this overwrites the existing 'geo_table.csv' file.

I would appreciate if you could help with this issue. Please feel free to ask for any additional details that you may require.

Best regards,

Dominant language
JavaScript
Stars
621
Forks
177
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rstudio/DT

All issues in rstudio/DT

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.