【问题标题】:Shiny - Text style for rows of renderTable / renderDataTableShiny - renderTable / renderDataTable 行的文本样式
【发布时间】:2023-03-09 08:05:02
【问题描述】:

如何在渲染表中以粗体显示前两行的文本?我可以在没有 DT/renderDataTable 的情况下执行此操作吗?

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    这个怎么样:

    shinyApp(
      ui = fluidPage(
        tags$head(
          tags$style(
            HTML("tr:first-child, tr:first-child + tr { font-weight: bold }")
          )
        ),
        fluidRow(
          column(12, tableOutput('table')
          )
        )
      ),
      server = function(input, output) {
        output$table <- renderTable(head(iris))
      }
    )
    

    【讨论】:

      【解决方案2】:

      试试这个:

      library(shiny)
      
      ui <- fluidPage(
          tags$head(
              tags$style(
                  "tr:nth-child(1) {font-weight: bold;}
                   tr:nth-child(2) {font-weight: bold;}
                  "
              )
          ),
          tableOutput("tbl")
      )
      
      server <- function(input, output){
      
          output$tbl <- renderTable({iris})
      }
      
      shinyApp(ui, server)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-12-21
        • 2023-03-24
        • 2014-01-07
        • 2018-07-18
        • 2021-08-04
        • 2021-02-11
        • 2014-10-09
        • 2014-02-28
        相关资源
        最近更新 更多