Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSV Export? #48

Open
ezgraphs opened this issue Jul 4, 2018 · 2 comments
Open

CSV Export? #48

ezgraphs opened this issue Jul 4, 2018 · 2 comments
Labels
enhancement New feature or request

Comments

@ezgraphs
Copy link

ezgraphs commented Jul 4, 2018

Thanks for the excellent ag-grid integration for Shiny!

Is it possible to enable grid csv export? I tried the following but it appeared to not affect the aggrid behavior.

RagGrid::aggrid(mtcars, list(showToolPanel=TRUE, suppressCsvExport=FALSE))

The underlying csv export is described in the ag-grid docs.

@vbisrikkanth
Copy link
Collaborator

vbisrikkanth commented Jul 5, 2018

Hi , Thanks for creating the issue. CSV export is achieved with an API call as explained in the docs and the example. So basically we need a button which would say "Export to CSV" and on click of the button we would need to call gridOptions.api.exportDataAsCsv(params). Here the params refer to the export settings as explained in the docs.

One way for us to handle this feature is - Add a button dynamically and place it on the top left/right and allow you to write the callback where you can perform the API call.

Another option - Add a context menu with Export to CSV an option.

We'll work on this feature for the next version. Thanks for using the package and your feedback.

@vbisrikkanth vbisrikkanth added the enhancement New feature or request label Jul 5, 2018
@vbisrikkanth vbisrikkanth added this to the Release 0.2.0 milestone Jul 5, 2018
@lelouch77
Copy link
Contributor

Hi @ezgraphs ,
With the help of shinyjs you can perform export to csv operation.
Here is an example shiny application..

library(shiny)
library(htmlwidgets)
library(shinyjs)

jsCode <- '
shinyjs.exportCsv = function() {
// You can also provide other export options here.. (https://www.ag-grid.com/javascript-grid-export/)
var exportOptions = {"fileName":"SampleExport.csv"};
window.tbl1.api.exportDataAsCsv(exportOptions); 
}'

ui <- shinyUI(fluidPage(
  useShinyjs(),
  extendShinyjs(text = jsCode),
  title = 'Use the RagGrid package in shiny',
  h1('A Table Using aggrid'),
  actionButton("btn", "Export Data"),
  fluidRow(
    column(2),
    column(8, RagGrid::RagGridOutput('tbl1')),
    column(2)
  )
))

server <- shinyServer(function(input, output, session) {
  observeEvent(input$btn, {
    js$exportCsv()
  })
  output$tbl1 <- renderRagGrid(
    aggrid(iris,options=list("onGridReady"=JS("function(event) { window.tbl1 =event;}")))
  )
})
# Run the application 
shinyApp(ui = ui, server = server)

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants