简体   繁体   中英

How to have an editable DT table when using Flexdashboard with shiny?

I don't know if this is the best approach, but any guidence is greatly appreciated. I have a table that in one of my flexdashboard's I will show applications. This table shows ID, date recieved, and a status which is blank.

I would like for a user to go in there and enter a status once they see application and have that status be saved in the table. I can do this with the editable=TRUE but it doesn't save when I reload my shiny app.

What is the best approach for this?

在此处输入图像描述

Code

---
title: "CARS TABLE "
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    runtime: shiny
---

```{r setup, include=FALSE}
library(flexdashboard)
library(shiny)
library(DT)
```

Column {data-width=650}
-----------------------------------------------------------------------

### Chart A

```{r}

data <- data.frame(id = c(12456,12457,12458,12459,12569,23456),
                   date_recived = c("10/25/2021", "10/05/2021","11/25/2021","11/25/2021","11/25/2021","10/22/2021"),
                   status = c("","","","","",""))

datatable(data
  ,
          editable = TRUE,
  options = list(
    columnDefs = list(list(className = 'dt-center', targets = "_all")))
)
```

In order to save user inputs, you'll need a server side process that would interact (read and write) with a database system or write to a file on the system.

Things is, {flexdashboard} is by definition an HTML file without a server side process, so as far as your example goes, there is no native way to do this with {flexdashboard} .

Your solutions are:

  • Turn into a {shiny} app.
  • Create a REST API (for example, with {plumber} or straight in NodeJS), then do a call in JavaScript from your HTML file. For example with https://api.jquery.com/jquery.post/ .

Colin

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM