Click here to Skip to main content
15,886,026 members
Articles / Programming Languages / Javascript

Enable or Disable All Tabs Except the Selected Tab inside the Telerik RadTabStrip

20 Sep 2014CPOL 9.7K   2  
In this post, we will explore the JavaScript code, by which we can easily enable or disable all the Tabs inside a Telerik RadTabStrip except the SelectedTab.

We will explore the JavaScript code, by which we can easily Enable or Disable all the Tabs inside a Telerik RadTabStrip except the SelectedTab. In my previous blog, we explored how to Enable or Disable all the Tabs. Now, let’s see how we can just do this for all the Tabs except the current Tab.

How This Is Helpful?

This kind of requirement comes when you have some business logic in a Tab (without saving the data), other Tabs can’t be accessible. Take one example, like, when you are registering something step by step. So, in the first tab, you will ask the user to enter some details and when he/she enters and hits register, you Enable all other Tabs, else just Disable.

How To?

If the Tab Text does not match with the SelectedTab‘s Text, then Disable it. Simple!!!

JavaScript
function DisableOtherTabs(){
    // Get the Tab Strip.
    var tabStrip = $find("<%= yourTabStripID.ClientID %>");

    // Get all the Tabs.
    var tabs = tabStrip.get_tabs();

    // Get Selected Tab.
    var selectedTab = tabStrip.get_selectedTab();

    // Now loop through all the Tabs and Disable one by one.
    for(var i = 0; i < tabStrip.get_allTabs().length; i++){
        // If the Tab Text does not match with the Selected Tab's Text, then Disable it. Simple !!!
        if(tabs.getTab(i).get_text().toUpperCase() != selectedTab.get_text().toUpperCase()){
            tabs.getTab(i).disable();
        }
    }
}

Thanks !!!

For taking time and reading the blog. If you find it useful, then share within your circle, by pressing the Social Icons.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Proud Indian | Author | TEDx Speaker | Microsoft MVP | CodeProject MVP | Speaker | DZone Most Valuable Blogger| jsfiddler

My Website

taditdash.com

Programming Community Profiles

jsfiddle | Stack Overflow

Social Profiles

Facebook | Twitter | LinkedIn

Awards


  1. DZone Most Valuable Blogger
  2. Microsoft MVP 2014, 2015, 2016, 2017, 2018
  3. Code Project MVP 2014, 2015, 2016
  4. Star Achiever of the Month December 2013
  5. Mindfire Techno Idea Contest 2013 Winner
  6. Star of the Month July 2013

Comments and Discussions

 
-- There are no messages in this forum --