locked
Clear all tabs (TabContainer) - $find('<%=TabContainer1.ClientID%>').get_tabs()[X].dispose(). RRS feed

  • Question

  • User1132102078 posted

    I am currently working on clearing all the dynamic generated tabs.

    I try to loop through all the tabs and dispose each one by one. I'm using $find('<%=TabContainer1.ClientID%>').get_tabs(); to get all the tabs.

    Too bad .. after all the tabs are dispose, the tabs are still there. Can anyone please help? Thanks .. any best way to write this? 

    Thank You,

    Monday, December 2, 2013 2:51 AM

Answers

  • User-227760790 posted

    hi ,

    i would suggest you use remove method

    function deleteTab(tab) {
    
                    var tabStrip = $find("<%= RadTabStrip1.ClientID %>");
    
                    var multiPage = $find("<%= RadMultiPage1.ClientID %>");
    
     
    
                    var pageView = tab.get_pageView();
    
                    var tabToSelect = tab.get_nextTab();
    
                    if (!tabToSelect)
    
                        tabToSelect = tab.get_previousTab();
    
     
    
                    tabStrip.trackChanges();
    
                    tabStrip.get_tabs().remove(tab);
    
                    tabStrip.commitChanges();
    
     
    
                    multiPage.trackChanges();
    
                    multiPage.get_pageViews().remove(pageView);
    
                    multiPage.commitChanges();
    
     
    
                    if (tabToSelect)
    
                        tabToSelect.set_selected(true);
    
                }
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 9, 2013 5:22 AM

All replies

  • User-933407369 posted

    hi slen,

    I would suggest you try to  check out the demo below:

    Dynamically generated tab closes on click

    http://www.telerik.com/community/forums/aspnet-ajax/tabstrip/dynamically-generated-tab-closes-on-click.aspx

     if it doesn't inspire you , you can post the complete  markup or provide a simple demo,which can easily reproduce the problem.

     In order to help us to understand your issue better.

    Thanks.

    Monday, December 2, 2013 9:58 PM
  • User1132102078 posted

    Thank You for both replies I received. 

    Actually I have also posted on the post as well. Sorry for double post. 

    I am following his example given. Unfortunaly, mine doesn't work. 

    below is my current code

    function clearTabPanels()
            {
                var tcContainer = $get('MainContent_tcContainer1');
    
                var arrTabs = $find('MainContent_tcContainer1').get_tabs();
                var totalTabs = arrTabs.length;
    
                var tabContainerID = tcContainer .id;
    
               
                for (var index = 0; index < totalTabs; index++)
                {
                    var activeTabPanel = arrTabs[0]; //--- this part I am not sure how to write as I think once an object is disposed, the array size would change
    
                    var j = index + 1;
                    var header = $get(tabContainerID + "_header");
                   
                    var headerTab = $get(tabContainerID + '_TabPanel' + (j)+'_tab');
                    header.removeChild(headerTab);
                   
                   
                    var body = $get(tabContainerID + "_body");
                    var bodyTab = $get(tabContainerID + "_" + 'TabPanel' + (j));
                    body.removeChild(bodyTab);
    
                    activeTabPanel.dispose();//-- here it doesn't dispose. After this line of code I use the get_tabs() I still can see the number of tabs remain in the TabContainer.
                   
    
                }
    
                
            }


    Thank You.

    Wednesday, December 4, 2013 7:27 PM
  • User-227760790 posted

    hi ,

    i would suggest you use remove method

    function deleteTab(tab) {
    
                    var tabStrip = $find("<%= RadTabStrip1.ClientID %>");
    
                    var multiPage = $find("<%= RadMultiPage1.ClientID %>");
    
     
    
                    var pageView = tab.get_pageView();
    
                    var tabToSelect = tab.get_nextTab();
    
                    if (!tabToSelect)
    
                        tabToSelect = tab.get_previousTab();
    
     
    
                    tabStrip.trackChanges();
    
                    tabStrip.get_tabs().remove(tab);
    
                    tabStrip.commitChanges();
    
     
    
                    multiPage.trackChanges();
    
                    multiPage.get_pageViews().remove(pageView);
    
                    multiPage.commitChanges();
    
     
    
                    if (tabToSelect)
    
                        tabToSelect.set_selected(true);
    
                }
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 9, 2013 5:22 AM