每当用户在tabsetPanel内的两个标签之间切换时,我都需要重置fileInput控件。
我已经查询了有关此主题的现有问题,但我们无法根据自己的需求量身定制。 how can I update a shiny fileInput object?
我没有清除按钮或刷新按钮 - 标签上的开关应该这样做。
以下是我的ui.R
fluidPage(
fluidRow(column(width=10,
tabsetPanel(id="tabPanelOptions",
tabPanel(value="FixedwidthTab", "Fixed width",
br(),
fluidRow(column(width=12, fileInput('layoutfile', 'Upload Excel file to define layout', accept = '.xlsx')))
),
tabPanel(value="DelimitedTab", "Delimited",
br(),
fluidRow(column(width=5, textInput("separator", "Field separator:",","))),
fluidRow(
column(width=5, checkboxInput("quotes","Quoted texts?",FALSE)),
column(width=5, checkboxInput("header","Files contains header (column names)",FALSE))
),
fluidRow(column(width=10, textInput("expcolumns", "Expected variables in file","27"))),
fluidRow(column(width=10, fileInput('headerfile', '(Optional) Upload CSV file to define attribute names', accept = c('text/csv','text/comma-separated-values', 'text/tab-separated-values', 'text/plain','.csv','.txt')))),
br(),
fluidRow(
column(width=5,conditionalPanel(condition= "input.header == false",uiOutput("choose_columns"))),
column(width=5,conditionalPanel(condition= "input.header == false", uiOutput("rename_columns"))))
)
)
)
)
)
用户可以在名为" FixedwidthTab"的第一个标签中上传文件。然后切换到名为" DelimitedTab"的第二个标签; - 反之亦然。两个选项卡都有fileInput控件,我需要它们在选项卡切换时重置。
答案 0 :(得分:0)
fileInputs
与一些服务器端呈现的UI交换,每当选择相应的选项卡时,它都会重新呈现shinyApp(
ui = shinyUI(
fluidPage(
fluidRow(column(width=10,
tabsetPanel(id="tabPanelOptions",
tabPanel(value="FixedwidthTab", "Fixed width",
br(),
fluidRow(column(width=12, uiOutput("file1")))
),
tabPanel(value="DelimitedTab", "Delimited",
br(),
fluidRow(column(width=5, textInput("separator", "Field separator:",","))),
fluidRow(
column(width=5, checkboxInput("quotes","Quoted texts?",FALSE)),
column(width=5, checkboxInput("header","Files contains header (column names)",FALSE))
),
fluidRow(column(width=10, textInput("expcolumns", "Expected variables in file","27"))),
fluidRow(column(width=10, uiOutput("file2"))),
br(),
fluidRow(
column(width=5,conditionalPanel(condition= "input.header == false",uiOutput("choose_columns"))),
column(width=5,conditionalPanel(condition= "input.header == false", uiOutput("rename_columns")))
)
)
)
))
)
),
server = function(input, output){
output$file1 <- renderUI({
if(input$tabPanelOptions == "FixedwidthTab"){
fileInput('layoutfile', 'Upload Excel file to define layout', accept = '.xlsx')
}
})
output$file2 <- renderUI({
if(input$tabPanelOptions == "DelimitedTab"){
fileInput('headerfile', '(Optional) Upload CSV file to define attribute names',
accept = c('text/csv','text/comma-separated-values','text/tab-separated-values',
'text/plain','.csv','.txt'))
}
})
}
)
。
见下面的代码:
{{1}}
如果您对提供的答案有疑问,请询问!