rstudio / DT

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

R shiny DT table with pagination and drop down list inside table and being able to save the entire updated table as csv file #1107

Closed sound118 closed 6 months ago

sound118 commented 6 months ago

Hi,

I have been experimenting with R shiny DT table with pagination and drop down list inside table and being able to save the entire updated table as csv file. It seems when I have pagination = FALSE, it can work as expected. However, in many use cases, we do need pagination = TRUE. I am referring to this stackoverflow page which works for pagination = FALSE. link: https://stackoverflow.com/questions/75948475/value-not-updated-in-shiny-using-dt-and-drop-down-selection/77706843#77706843 Can anyone help to improve it to be able to save the entire updated data table as csv file with pagination = TRUE?

Thanks


By filing an issue to this repo, I promise that

I understand that my issue may be closed if I don't fulfill my promises.

stla commented 6 months ago

Search "cellEdit" in my StackOverflow answers within the [dt] tag, e.g. this answer.

sound118 commented 6 months ago

I checked your stackoverflow page. Actually this is not quite what I want. What I want is drop down list inside data table with fixed choices, not simply editting cells. I actually have some testing R shiny code here, but there's problem with it. The issue is when I click into other pages other than first page and select a choice from drop down list, it always goes back to first page. The code and the base csv file are in attached files, could you pls help to fix this? Many thanks!

sound118 commented 6 months ago

saved_data.csv app_dropdown.txt Please use above two files to run my testing r shiny app!

kit-hcrn commented 6 months ago

Make sure you use server = FALSE in RenderDataTable. DT only loads the current page to the browser when using server = TRUE.

sound118 commented 6 months ago

I resolved this issue by adding isolate function around rv$data in datatable function call.