TabBar onTabClose event

Hi,

I’m newbie with Dhtmlx … :open_mouth: . All is working OK . I have dinamically adding and closing tabs . In tabs are contents with grids . I wanna to do that at the moment then closing tab to save grids columns widths and orders . But can’t to catch onTabClose event .

         tabbar = new dhtmlXTabBar( "pagrTabs", "top" );
         tabbar.setSkin( 'dhx_skyblue' );
         tabbar.setImagePath( "codebase/imgs/");
         tabbar.enableTabCloseButton( false );
         tabbar.addTab( "pagr_Men", "Main Menu" );
         tabbar.setLabel( "pagr_Men", "Main menu", 130 );
         tabbar.enableAutoSize( true, true );
         tabbar.setContent( "pagr_Men", "pagrMen" );
         tabbar.setTabActive( "pagr_Men" );
         tabbar.attachEvent( "onTabClose", function( tabId )
         {
            debugger;
            tabbar.tabWindow( id ).mygrid.saveSizeToCookie();
            tabbar.tabWindow( id ).mygrid.saveSortingToCookie();
            tabbar.tabWindow( id ).mygrid.saveOrderToCookie();
            return true;
         });
      }

      function adTab( tabID, tabName, cHtml )
      {
         var tab = tabbar._tabs[ tabID ];
         var nLn = 0;
         if ( !tab )
         {
            tabbar.enableTabCloseButton( true );
            tabbar.addTab( tabID, tabName, "200px" );
            nLn = parseInt( tabName.length * 9 ) + 35;
            tabbar.setLabel( tabID, tabName, nLn );
            if ( cHtml )
            {
               tabbar.setHrefMode( "ajax-html" );
               tabbar.setContentHref( tabID, cHtml + ".html" );
            }
         }
         tabbar.setTabActive( tabID );
      }

As you can see I inserted “debugger” line to stop at this moment , then closing tab . Working with Google Chorme . But JS console didn’t stop there … :confused:

Many thanks in advance !

Sorry , noticed that I did small mistake … OnTabClose I direceted “tabId” , changed to “id” . But the result the same … :frowning:

Hi ,

At this morning I tried to catch “onTabClose” event and … that worked ! Now debugger is stopping . But at this moment I have another problem - how to detect grid ? This line I found in forum : tabbar.tabWindow( id ).mygrid . But onTabClose I’m getting “Uncaught TypeError: Cannot read property ‘contentWindow’ of null” .

So how to detect grid inside dinamically created/closed tab page ?

With best regards !

Hi

Attaching a sample for you with your issue, but with Tree, not Grid.
Approaches are absolutely identical, but I won’t attach professional versions on forum.

How to reproduce:

  1. close “Tab 1”
  2. click a button “click”
  3. gain the new tab “Tab 3” with your tree from the first tab.

See attaches (and i wrote too you some more information in the support).
tabbar_onClose.rar (80.6 KB)