【问题标题】:How to disable a tabPanel in shinydashboard?如何禁用闪亮仪表板中的tabPanel?
【发布时间】:2016-05-24 02:27:34
【问题描述】:

有没有办法在点击 actionButton 之前禁用 tabPanel?我尝试使用 shinyjs 来做到这一点,但没有奏效。目前我的 ui.R 有以下代码。在单击 loadButton 之前,我想禁用“过滤器”tabPanel。 `

body <- dashboardBody(
    useShinyjs(),
    tabsetPanel(id = "tabs", type = 'pills',
        tabPanel("Load", dataTableOutput("loadTab")),
        tabPanel("Filter", id='filterTab',dataTableOutput("filteredResults"))
    ))
sidebar <- dashboardSidebar(
        sidebarMenu(
         selectInput(inputId = "datasetName",label = 'Dataset',  choice=c('Cancer','Normal')),
         actionButton("loadButton", label = "Load")
        ))

` 任何帮助表示赞赏。

【问题讨论】:

    标签: r tabpanel shinydashboard


    【解决方案1】:

    我让它与 shinyjs 一起工作。 `

        jsCode <- "
    shinyjs.disableTab = function() {
        var tabs = $('#tabs').find('li:not(.active) a');
        tabs.bind('click.tab', function(e) {
            e.preventDefault();
            return false;
        });
        tabs.addClass('disabled');
    }
    shinyjs.enableTab = function(param) {
        var tab = $('#tabs').find('li:not(.active):nth-child(' + param + ') a');
        tab.unbind('click.tab');
        tab.removeClass('disabled');
    }
    

    " ` 然后根据需要启用和禁用选项卡。

    【讨论】:

    • 我一直在使用您的答案来根据需要启用和禁用选项卡,但我意识到如果 tabPanel() 中的 title 包含空格,则它不起作用。如何修改您的 jsCode纠正这个问题?
    • 你能提供一个带有ui和服务器功能的MWE吗?
    猜你喜欢
    • 1970-01-01
    • 2020-12-03
    • 2015-04-22
    • 1970-01-01
    • 1970-01-01
    • 2019-02-12
    • 2020-03-04
    • 2019-06-20
    • 2016-05-02
    相关资源
    最近更新 更多