在从 RODBC 检索到的闪亮 DropDownList 上刷新 selectInput
Refresh selectInput on shiny DropDownList retrieved from RODBC
我在 ShinyUI Tab1 中有一个反应输入:
selectInput("SelectVar", choices = DropDownListForVar())
,其中
DropDownListForVar()) = function (){
sqlQuery = return ( Connection, "Select var from dbo.Variables")
} ## using RODBC library
在我闪亮的应用程序中,我还更新了 Tab2 中的 dbo.Variables table。问题是我无法从 Tab1 中看到 dbo.Variables 中的更新值,除非我重新启动应用程序。
有什么想法吗?
没有可重现的例子很难调试。我猜你缺少 reactive context for selectInput
or data retrieval. Please make sure to update the dropdown using updateSelectInput
and fetch the data with a reactive expression, both inside server. Additionally, to achieve this goal, you need to inform your Shiny App automatically when the database is updated, which could be hard to implement. I would suggest triggering queries with an action button or timer (reactiveTimer
)
我在server.R中使用了updateSelectInput
:
updateSelectInput(session ,"SelectVar", choices = DropDownListForVar())
在更新 "SelectVar" 后触发并且工作正常。
就我而言,了解数据库何时更新很容易,因为一次只有一个用户在单击按钮时添加记录。谢谢!
我在 ShinyUI Tab1 中有一个反应输入:
selectInput("SelectVar", choices = DropDownListForVar())
,其中
DropDownListForVar()) = function (){
sqlQuery = return ( Connection, "Select var from dbo.Variables")
} ## using RODBC library
在我闪亮的应用程序中,我还更新了 Tab2 中的 dbo.Variables table。问题是我无法从 Tab1 中看到 dbo.Variables 中的更新值,除非我重新启动应用程序。
有什么想法吗?
没有可重现的例子很难调试。我猜你缺少 reactive context for selectInput
or data retrieval. Please make sure to update the dropdown using updateSelectInput
and fetch the data with a reactive expression, both inside server. Additionally, to achieve this goal, you need to inform your Shiny App automatically when the database is updated, which could be hard to implement. I would suggest triggering queries with an action button or timer (reactiveTimer
)
我在server.R中使用了updateSelectInput
:
updateSelectInput(session ,"SelectVar", choices = DropDownListForVar())
在更新 "SelectVar" 后触发并且工作正常。
就我而言,了解数据库何时更新很容易,因为一次只有一个用户在单击按钮时添加记录。谢谢!