Shiny 数据表中的回调
通常,我希望在表格的最后一行应用样式(边框顶部和fontWeight)。但是在我的应用程序中有一些表格,我不想在最后一行应用这种样式。我在DT中使用callback()来解决这个问题,但它不适用于server=TRUE选项。我对server=FALSE的问题是,它返回一些奇怪的格式,加载速度较慢。使用server=TRUE有其他解决方案吗Shiny 数据表中的回调,shiny,dt,Shiny,Dt,通常,我希望在表格的最后一行应用样式(边框顶部和fontWeight)。但是在我的应用程序中有一些表格,我不想在最后一行应用这种样式。我在DT中使用callback()来解决这个问题,但它不适用于server=TRUE选项。我对server=FALSE的问题是,它返回一些奇怪的格式,加载速度较慢。使用server=TRUE有其他解决方案吗 shinyApp( ui = fluidPage( tags$head( tags$style( HTML("
shinyApp(
ui = fluidPage(
tags$head(
tags$style(
HTML("
table.dataTable tr:last-child td {
border-top: 1px solid #111 !important;
font-size: 13px;
font-weight:600;
color: #1c273c;
letter-spacing: .5px;
}"))),
fluidRow(
column(12,
dataTableOutput('table')
)
)
),
server = function(input, output) {
test.table <- data.frame(lapply(1:8, function(x) {1:1000}))
test.table[c(2,3,7), c(2,7,6)] <- NA
id <- which(is.na(test.table))
output$table <- renderDataTable({
DT_ignorelast <- function() DT::JS("$('table.dataTable tr:last-child td').attr('style', 'border-top : none !important; font-weight', '400');")
datatable(
test.table,
callback = DT_ignorelast())
},
server = TRUE)
}
)
shinyApp(
ui=fluidPage(
标签$head(
标签$style(
HTML(“
table.dataTable tr:最后一个子项td{
边框顶部:1px实心#111!重要;
字体大小:13px;
字号:600;
颜色:#1c273c;
字母间距:.5px;
}"))),
fluidRow(
第(12)栏,
dataTableOutput('表')
)
)
),
服务器=功能(输入、输出){
test.table这是您想要的吗
library(shiny)
library(DT)
css <- "
.lastRow {
border-top: 1px solid #111 !important;
font-size: 13px;
font-weight: 600;
color: #1c273c;
letter-spacing: .5px;
}
"
drawCallback <- JS(
"function(settings){",
" var table = this.api();",
" var nrows = table.rows().count();",
" $(table.row(nrows-1).node()).find('td').addClass('lastRow');",
"}"
)
shinyApp(
ui = fluidPage(
tags$head(
tags$style(HTML(css))
),
fluidRow(
column(12,
DTOutput('table')
)
)
),
server = function(input, output) {
test.table <- data.frame(lapply(1:8, function(x) {1:1000}))
test.table[c(2,3,7), c(2,7,6)] <- NA
id <- which(is.na(test.table))
output$table <- renderDT({
datatable(
test.table,
options = list(
drawCallback = drawCallback
)
)
},
server = TRUE)
}
)
库(闪亮)
图书馆(DT)
css