Sounds good! thanks Jiena.
Can you please provide the code as well
also I tried with another way here is the code
library(shiny)
library(DTedit)
mydata1 <- read.csv('Item_master.csv', row.names = NULL)
##### Create the Shiny server
server <- function(input, output) {
mydata <- data.frame(Sr =numeric(),
Category=character(),
Item=character(),
Weight=numeric(),
SKUNo=character() ,
SellingPrice =numeric(),
Costprice =numeric(),
Overheads =numeric(),
stringsAsFactors = FALSE)
mydata <- as.data.frame(mydata1)
##### Callback functions.
my.insert.callback <- function(data, row) {
write.csv(data, file = "item_master.csv", row.names = FALSE, col.names = TRUE)
mydata <-data
#rbind(data, mydata)
return(mydata)
}
my.update.callback <- function(data, olddata, row) {
mydata[row,] <- data[1,]
mydata<-data
write.csv(mydata, file = "item_master.csv")
return(mydata)
}
my.delete.callback <- function(data, row) {
mydata <- data[-row,]
write.csv(mydata, file = "item_master.csv", row.names = FALSE, col.names = TRUE)
return(mydata)
}
##### Create the DTedit object
DTedit::dtedit(input, output,
name = 'mycontacts',
thedata = mydata,
edit.cols = c('Sr', 'Category','Item','Weight','SKUNo' ,'SellingPrice','Costprice','Overheads'),
edit.label.cols = c('Sr', 'Category','Item','Weight','SKUNo' ,'SellingPrice','Costprice','Overheads'),
#input.types = c(notes='textAreaInput'),
view.cols = c('Sr', 'Category','Item','Weight','SKUNo' ,'SellingPrice','Costprice','Overheads'),
callback.update = my.update.callback,
callback.insert = my.insert.callback,
callback.delete = my.delete.callback
#mydata1 <- as.data.frame(mydata),
)
}
##### Create the shiny UI
ui <- fluidPage(
#actionButton("addButton", "UPLOAD!")
h3('DTedit Template'),
uiOutput('mycontacts')
)
##### Start the shiny app
shinyApp(ui = ui, server = server)