I am running an R Shiny web-app. I used datatables to show the data. But I want the inline editing of cell of the tables. I am unable to do that. Can any one guide me?
Here is my code in
# UI.R
fluidRow(
column(4,dataTableOutput("numericalBin")),
column(8,h1("numericalBin_Chart")))
)
# Server.R
output$numericalBin <- renderDataTable({
mtcars
},options = list(
lengthChange=FALSE,
searching=FALSE,
autoWidth=TRUE,
paging=FALSE
))
I want to edit cell. Here is the link I want to do the effect:
https://editor.datatables.net/examples/inline-editing/simple.html
I need something to add in option list maybe but I can not find the right one.
Apart from DT prototype proposed by @dracodoc, another option is using rhandsontable package.
EDIT: according to comments by @hveig and @Munawir, a piece of working example code is now attached (adapted from rhandome examples page):
library(shiny)
library(rhandsontable)
shinyApp(
shinyUI(
fluidRow(
rHandsontableOutput("hot")
)),
shinyServer(function(input, output, session) {
values = reactiveValues()
data = reactive({
if (!is.null(input$hot)) {
DF = hot_to_r(input$hot)
} else {
if (is.null(values[["DF"]]))
DF = mtcars
else
DF = values[["DF"]]
}
values[["DF"]] = DF
DF
})
output$hot <- renderRHandsontable({
DF = data()
if (!is.null(DF))
rhandsontable(DF, stretchH = "all")
})
})
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With