Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable a tabPanel in shinydashboard?

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.

like image 520
Sri Paladugu Avatar asked May 23 '16 03:05

Sri Paladugu


1 Answers

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.

like image 115
Sri Paladugu Avatar answered Oct 03 '22 06:10

Sri Paladugu