Best databound text field process?

What would be the best approach to bi-synchronize Google Sheets data connected to editable text entry fields (read/write)?

Please view the development shiny app and click on a data table row to view form text fields.
https://literateaspects.shinyapps.io/0001/

The overall goal is to mimic this: https://i.imgur.com/LPMEMBq.png

Adding a data table with editable form data entry fields.

Any suggestions greatly appreciated.

1 Like

Because it's directly linking to Google Sheets, it's going to be a custom implementation.

Communication points to cover:

  • User Edit
    • Shiny Table to R
    • R to Google Sheets
  • Sheets Edit
    • Google Sheets to R
    • R to Shiny Table

Shiny Table to R

DT can have editable tables. See https://rstudio.github.io/DT/ Section 2.3
Demo of getting information to R from the Browser: https://yihui.shinyapps.io/DT-edit/

R to Google Sheets

See the googlesheets R package https://cran.r-project.org/web/packages/googlesheets/vignettes/basic-usage.html

Google Sheets to R

You could maintain a last_updated value. Have a method poll every k seconds to check if the table has been updated.

Ex:

k <- 5
last_updated <- reactiveVal(as.Date("1970-01-01"))
observe({
  
  last_sheet_updated <- ... # look up google sheet last updated time
  if ( isolate(last_updated()) - last_sheet_updated < 0) {
    # set the last updated time
    isolate(last_updated(last_sheet_updated))
    # update the browser
    update_user_table_method() # must be created
  }

  # Test again in k seconds
  invalidateLater(k * 1000)
})

R to Shiny Table

Look for DT::dataTableProxy. See section 2.3: https://rstudio.github.io/DT/shiny.html .
Demo: https://yihui.shinyapps.io/DT-proxy/


** Code untested

Thank you. Shall try and reply.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.