我一直在尝试使用带有dateInput. 问题是日历小部件隐藏在模态后面。这是我的示例代码:
library(shiny)
library(shinyBS)
shinyApp(
ui =fluidPage(
mainPanel(
actionButton("button", label = "Open Modal"),
bsModal("modalExample", "Data Table", "rowtogg", size = "small",
fluidPage(dateInput("dates", "Enter date")))
)
),
server = function(input, output, session) {
observeEvent({
input$button
},{
toggleModal(session, "modalExample", "open")
})
}
)
Run Code Online (Sandbox Code Playgroud)
问题的截图可以在:https : //github.com/ebailey78/shinyBS/issues/46找到,我已经在那里问过这个问题。但是在我看来这是一个更“普遍”的问题,所以我希望这里有人可以帮助我。
编辑:感谢 Yenne Info 它通过添加以下内容来工作:
tags$style(type = "text/css", ".datepicker{z-index: 1100 !important;}"),
Run Code Online (Sandbox Code Playgroud) 我的modalDialog 的标题是一个reactiveValue。一旦在模态中更改了某个输入,我希望标题也更改。我尝试了几种不同的方法,但无法让它无缝地工作。标头要么不更新,要么仅在我关闭/重新打开模态时更新,要么在标头立即更新时导致模态完全重新呈现。
目前,我被困在最后一个(完全重新渲染模式)。但是,当我创建最小的、可重现的示例(如下)时,标题仅在我关闭并重新打开模态时更新。
ui<-fluidPage(
actionButton(inputId="model", label="Edit Model")
)
server<-function(input, output, session) {
rv<-reactiveValues(header="Standard Model")
observeEvent(input$model, {
showModal(
modalDialog(
fluidPage(
fluidRow(h3(rv$header)),
sliderInput(inputId="factor_1", "Factor #1", value=70, min=0, max=100),
sliderInput(inputId="factor_2", "Factor #2", value=30, min=0, max=100)
),
footer=modalButton("Save Weights"), size="s", easyClose=TRUE
)
)
})
observe({if (!is.null(input$factor_1)) {
if (input$factor_1!=70) {
rv$header<-"Custom Model"
}
}
})
}
shinyApp(ui=ui, server=server)
Run Code Online (Sandbox Code Playgroud)
本质上,一旦因子 #1 的输入第一次更改,我希望标题从“标准模型”更改为“自定义模型”(无需关闭/重新打开或重新呈现模式)。
我正在尝试使用 styleInterval (在 DT 包的 formatStyle 内)将条件格式应用于数据表的一行。我在网上找到的所有示例要么用于格式化整个数据表,限制涉及的列,要么根据单列中的值格式化整个行。
我想将涉及的行限制为以下示例中的第一行(“entity1”)。
entity <- c('entity1', 'entity2', 'entity3')
value1 <- c(21000, 23400, 26800)
value2 <- c(21234, 23445, 26834)
value3 <- c(21123, 234789, 26811)
value4 <- c(27000, 23400, 26811)
entity.data <- data.frame(entity, value1, value2, value3, value4)
DT::datatable(entity.data) %>%
formatStyle(columns = 2:5,
backgroundColor = styleInterval(cuts = c(21200,22000),
values = c('red','white','green')))
Run Code Online (Sandbox Code Playgroud)
我是否缺少使用 formatStyle 执行此操作的方法,或者我是否需要使用另一个函数/包来解决此问题?谢谢!