ebailey78 / shinyBS

Twitter Bootstrap Components for Shiny
182 stars 47 forks source link

Can't get shinyBS to work at all #19

Closed bogdanrau closed 9 years ago

bogdanrau commented 9 years ago

Hi ebailey78,

Thanks so much for a great package! The demo works great, however, I can't seem to get it to work in my app. Any input? I'm trying to: 1. use bsActionButton instead of actionButton; and 2. highlightRows, neither of which seem to work. Thinking it has to do with shiny not loading....

ui.R:

source("choices.R")
source("inputOptions.R")
library(shiny)
library(shinyBS)
## Begin ShinyUI
shinyUI(fluidPage(

## Set title of the page (includes <h1> tag)
titlePanel(""),

## Set up page with a sidebar and main panel
sidebarLayout(
    sidebarPanel(
        fluidRow(
            column(12, h5("Customize your query below:")),
            column(12, selectInput("population", label = h6("Select Population"), choices = population)),
            column(12, selectInput("year", label = h6("Select Year"), choices = year)),
            column(12, selectInput("locationType", label = h6("Select Geographic Level"), choices = geography)),
            conditionalPanel(
                condition = "input.locationType == 'Counties'",
                column(12, selectizeInput("coLocation", h6("Select County"), choices = counties, options = coOptions))
                ),
            conditionalPanel(
                condition = "input.locationType == 'Regions'",
                column(12, selectizeInput("regLocation", h6("Select Region"), choices = regions, options = regOptions))
                ),
            column(12, bsActionButton("getResults", label = "Get results!"))
            )
        ),

    mainPanel(
        textOutput("cycle"),
        dataTableOutput("results")
        )
    )

))

server.R:

library(shiny)
library(shinyBS)  
shinyServer(function(input, output, session) {
    updateButton(session, "getResults", style = "default", size = "default", disabled = FALSE)
    output$results <- renderDataTable({

    input$getResults ## Take a dependency on input$getResults button
    if(input$getResults == '0') { return() } ## Initial load with no button press, show nothing
    else {

        data <- isolate( ## Create data by concatenating different values from the input fields
            read.csv(file = paste("data/", input$year, "/", input$population, "/", input$locationType, "/",
                                  input$coLocation, ".csv", sep=""), check.names = FALSE)
            )
        highlightRows(session ,'results', column = "2", class = "info")
        print(data, type='html') # Print data to console to show on screen

    }

},
options = list( # data table options to remove certain additional/advanced features
    column.searchable = FALSE,
    searching = FALSE,
    paging = FALSE,
    ordering = FALSE
)

)

output$cycle <- renderText("The data in this website is fictitious.")

})

bogdanrau commented 9 years ago

I should mention that I also tried removing the package, then installing with sudo R

ebailey78 commented 9 years ago

Are you installing the version in the shinyBS3 branch?

devtools::install_github("ebailey78/shinyBS", ref = "shinyBS3")

That is the newest version, updated to work with shiny v0.11 and Twitter Bootstrap 3.