How to disable a tabPanel in shinydashboard?

此生再无相见时 提交于 2019-12-07 14:01:29

问题


Is there a way to disable a tabPanel until an actionButton is clicked? I tried to do this using shinyjs but that did not work. Currently my ui.R has the following code. I want to disable 'Filter' tabPanel until loadButton is clicked. `

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")
        ))

` Any help is appreciated.


回答1:


I got it working with 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');
}

" ` And then enabling and disabling tabs as needed.



来源:https://stackoverflow.com/questions/37382091/how-to-disable-a-tabpanel-in-shinydashboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!