Reputation: 90
I am having trouble seeing how to use the esquisse package to support the searchbar feature here. I want to be able to filter through a name. For example, if someone were to search setosa, it would return a formatted table that is subsetted. I was looking through the esquisse package, but I wasn't sure how to integrate it into a Shiny Dashboard. it seems like I need to change the output in the server.
library(tidyverse)
library(janitor)
library(shinydashboard)
library(shiny)
library(formattable)
library(golem)
library(esquisse)
#Loading Dummy Data
data(iris)
summary(iris)
df <- iris
formattable(df)
ui <- dashboardPage(
dashboardHeader(title = "Title"),
dashboardSidebar(sidebarSearchForm(label = "Name", "searchText", "searchButton")),
dashboardBody(formattableOutput("table"))
)
server <- function(input, output) {
output$table <- renderFormattable({ formattable(df, align = c("l",rep("r", ncol(df))), list(
`Indicator Name` = formatter("span", style = ~ style(color = "grey",font.weight = "bold")),
area(col = 2:length(df)) ~ color_tile("#DeF7E9", "#71CA97")))})
}
shinyApp(ui = ui, server = server)
Upvotes: 1
Views: 786
Reputation: 66
You can use as.datatable
as shown below:
as.datatable(
formattable(blah blah blah)
)
Also if you want to use datatable options and filters etc. use them as shown below:
as.datatable(
formattable(blah blah blah)
,filter = 'top', rownames = FALSE)
See below for example: to see where to place your datatable
editing features and where to place your formattable
editing features:
as.datatable(
formattable(mydata,
align = c("l",rep("r", NCOL(mydata) - 1)),
list(`column_1` = formatter("span", style = ~ style(color = "grey", font.weight = "bold")),
`column_2` = formatter("span", style = ~ style(color = "blue")),
`column_3` = formatter("span", style = ~ style(color = "black")),
`column_4` = formatter("span", style = ~ style(color = "red", font.weight =
"bold"))
))
,filter = 'top', rownames = FALSE)
Upvotes: 2