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

Populating bs4Table with data #200

Closed
Camil88 opened this issue Apr 6, 2021 · 1 comment
Closed

Populating bs4Table with data #200

Camil88 opened this issue Apr 6, 2021 · 1 comment

Comments

@Camil88
Copy link

Camil88 commented Apr 6, 2021

Hello, I'm trying to populate bs4Table with data but don't know how to do it on server/ui side. It's quite easy with renderDataTable, here is an example:

  shinyApp(
    ui = fluidPage(
      fluidRow(
        column(12,
          dataTableOutput('table')
        )
      )
    ),
    server = function(input, output) {
      output$table <- renderDataTable(iris)
    }
  )
}

Both server and ui side are easy to implement, is it possible to do something like that with bs4Table?
I browsed opened/closed issues here, I also couldn't find any render-like functions dedicated for table in bs4Dash.

@DivadNojnarg
Copy link
Member

Hi. I simplified the API so that we only need bs4Table:

library(shiny)
 library(bs4Dash)
 
 shinyApp(
  ui = dashboardPage(
    header = dashboardHeader(), 
    sidebar = dashboardSidebar(),
    body = dashboardBody(
     bs4Table(
      cardWrap = TRUE,
      bordered = TRUE,
      striped = TRUE,
      iris
     )
    ), 
    footer = dashboardFooter()
  ),
  server = function(input, output) { }
 )

You can also pass a named list of shiny tags as input like:

bs4Table(
        cardWrap = TRUE,
        bordered = TRUE,
        striped = TRUE,
        list(
          list(
            income = "$2,500 USD", 
            status = dashboardBadge(
              "Pending",
              position = "right",
              color = "danger",
              rounded = TRUE
            ), 
            progress = progressBar(value = 50, status = "pink", size = "xxs"), 
            text = "test", 
            confirm = actionButton(
              "go",
              "Go"
            )
          ),
          list("$2,500 USD", "NA", "NA", "test", "NA")
        )
      )

On the server side you would use renderUI as there is not renderBs4Table at the moment.

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

No branches or pull requests

2 participants