DT::dataTableProxy

Hello,

Following the different remark from nirgrahamuk of the message here, I made my code with dataTableproxy.
The code is well done, i.e. when I edit a line I can modify it.
Now I would like to save the values in the table I edited. I tried with coerceValue but it doesn't work. I think I didn't understand how to return the values from the proxy to the table I edited.
Do you have an idea or some advice?
Thanks in advance

# global.R 
#
rm(list = ls())
library(DT)
library(shiny)
library(shinydashboard)
library(dashboardthemes)
library(dplyr)
library(lubridate)

#ui.R 
df<-data.frame(
        ECR= c("040/19", "050/20"),
        BEM=as.Date(c("2020/03/01", "2020/02/01")),
        BEE=c("", ""),
        FIN=c(4,-5)
)

ui<-fluidPage(DT::dataTableOutput(outputId ="data.tab"),
             actionButton(inputId = "edit",label = "Edit",color="green",class="butt4")
            )

# Server.R
server<-function(input, output,session) {
  
              mod_df <- shiny::reactiveValues(x = df)
              
              output$data.tab <- DT::renderDataTable({
                                DT=df
                                datatable(DT,selection = 'single',
                                escape=F,rownames = FALSE) 
              })
                
              observeEvent(input$edit,
                           {
                             showModal(modalDialog(
                                       infoBox("ECR CARD", uiOutput("card"), icon = icon("line-chart")),
                                       DT::dataTableOutput('tab'),
                                       actionButton("save","Save changes")
                             ))
                             }
                           )
              
              output$tab <- DT::renderDT({
                                selected_row=input$data.tab_rows_selected
                                mod_df<-mod_df$x[selected_row,]
                                isolate(mod_df)
                                #print(mod_df)
                                }, escape=FALSE,selection = 'none',editable="all",rownames=FALSE
                                )
              
              val<-eventReactive(input$edit,{
                            selected_row=input$data.tab_rows_selected
                            mod_df<-mod_df$x[selected_row,]
                            mod_df
              })
              
              output$card<- renderText({
                            val.ecr<-val()
                            prettyNum(paste0(val.ecr[1,1]))
              }) 
              
              proxy <- DT::dataTableProxy('tab')
              
              shiny::observe({DT::replaceData(proxy, mod_df$x)})
              
              #######save 
              observeEvent(input$save,{
                
                              })
    
}
shinyApp(ui, server)

Hi, I added the observEvent to the code base on link but the value is not saved in tab in "pop-up" .(see picture below)
Have you an idea?

    observeEvent(input$tab_cell_edit, {
                          info = input$tab_cell_edit
                          str(info)
                          i = info$row
                          j = info$col + 1
                          v = info$value
                          mod_df$x[i, j]<<- DT::coerceValue(v, mod_df$x[i, j])
                          replaceData(proxy, mod_df$x, resetPaging = FALSE) 
                })

So the observe event return in Rconsol (the value is the value that I've modified

Listening on http://127.0.0.1:6532
'data.frame':	1 obs. of  3 variables:
 $ row  : int 1
 $ col  : int 2
 $ value: chr "60"

Hi, I exchanged on the subject to save modifications made in modal dialogue and apparently it is not possible with datatableproxy. Apparently I have to use Javascript the problem I don't know JS. I wanted to do the code with 100% R.
You can find my exchanges here. https://stackoverflow.com/questions/65048659/dtdatatableproxy-save-the-data-in-table/65125919?noredirect=1#comment115254477_65125919
Did you have any idea ?
Thanks in advance

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.