0

I have a handson table which can be like this- ID REgularCost Sales Margin 1 100 90 10

Now i want a button which will save this table after making appropriate changes. For e.g. if i change regular cost to 110. Then it automatically compute margin to be 20 and display a new updated table with new values. How can i do this in r shiny using handsontable?

Varun
  • 1
  • 2

1 Answers1

0

Well, the solution is to first make your button running a function. This is possible with the shinyjs package.

first load the package in both Ui.R and Server.R

 library(shinyjs)

Initialize shinyjs:

shinyUI(fluidPage(
  shinyjs::useShinyjs(),

then add in the Ui.R a new button

        uiOutput("processInt"),

Change the initializing code for Server.R to (add the session command)

shinyServer(function(input, output, session) {

In the Server.R you then have defined the button

output$processInt <- renderUI({
    actionButton("process","Start")
})

Then add the java script functionality to start a function from the button

 onclick("process", {
     Results() 
})    

Now you can call your function that does the change for the table as you want it.

Robin K
  • 68
  • 6
  • Thanks Robin. I think i am missing something since i am new to r and r-apps. – Varun Jul 11 '16 at 12:39
  • Thanks,can you suggest what is wrong here:UI<-dashboardPage( dashboardSidebar(fileInput("file","Upload")), dashboardBody(shinyjs::useShinyjs(), actionButton("b1","Get D1"),rHandsontableOutput('D1'), uiOutput("pInt"))))) server<-shinyServer(function(input,output,session){D1<-reactive({ file1<-input$file read.csv(-code-) D1<-eventReactive(input$b1,{final<-D1() #-D1 code-)]}) output$D1<-renderRHandsontable({rhandsontable(D1())) output$pInt<-renderUI({ actionButton("process","Update")}) onclick("process",{Res()}) Res<-function(){bd<-D1() bd$Margin<-bd$Retail-bd$COST return(bd)} – Varun Jul 11 '16 at 13:39
  • Because of the word restriction...i have restricted it and hence it might look messy...If possible please suggest what can be done – Varun Jul 11 '16 at 13:40