DEV Community

Discussion on: Reactive DataTables in R with Persistent Filters

Collapse
 
tahorsuijuris profile image
TahorSuiJuris • Edited

Outstanding!!! Thank you.

Q1. Would you have any suggestions on how to fix the column display to 8 columns?

Q2. Would you have any suggestions on how to post data bi-directionally after edit? Please see:

community.rstudio.com/t/bi-directi...

library(flexdashboard) # Flexdashboard to create a frame for the content
library(dplyr)         # tidy data manipulation
library(leaflet)       # Leaflet for the interactive map
library(DT)            # DT for the interactive table
library(crosstalk)     # Crosstalk for widget interactivity
library(shiny)         # Shiny web app to broaden the capabilities of Crosstalk

# Ion icons and Font Awesome for icons

# user interface just shows the table
ui <-
    fluidPage(
        title = 'Base List Table',
        h1('Base List Using Server-side Processing'),
        fluidRow(column(8, div(
#TODO:  FIX COLUMNS TO DISPLAY 8        
        dataTableOutput("dataTable")
    ))))

# server is where all calculations are done, tables are pre-rendered
server <- function(input, output, session) {
    # load CSV file
    myCSV <-
        read.csv(
            'https://docs.google.com/spreadsheets/d/e/2PACX-1vToTirzRAHEuMiBXMOt5eyWVK342PnU2mpjl3nZCaveQdWPoFpXeX-oMhPZDZDhk9hBbOtUWQn0w29H/pub?output=csv'
        )
    #-----------------------------------------------------------------------------
    #  render data table
    #-----------------------------------------------------------------------------

    output$dataTable <- renderDT(myCSV,
                                 # data
                                 class = "display nowrap compact",
                                 # style
                                 filter = "top",
                                 # location of column filters
                                 editable = TRUE)
                                 # cells editable
}

# run the app
shinyApp(ui, server)