Skip navigation
Currently Being Moderated

Getting child of SuperTabNavigator/TabNavigator

Oct 30, 2013 8:03 PM

Tags: #supertabnavigator

Hi,

 

I have several components (Box with ID with AdvancedDataGrid) added as children to SuperTabNavigator.

Need to get a handle to such child component to refresh its DataGrid's data

(or possibly to close it and open another one like that with new data).

 

So how can I get a handle to the child of SuperTabNavigator?

And how can I check whether such Box with ID already exists in SuperTabNavigator or not?

 

(I think, answer for TabNavigator would help too)


--
Thank you in advance,
Oleg.
 
Replies
  • Currently Being Moderated
    Nov 1, 2013 1:31 AM   in reply to olegkon

    if the handle is public, you can invoke like this SuperTabNavagator.boxID.handle

     

    can you give some example code

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 2, 2013 5:13 AM   in reply to olegkon

    may be you can loop superTabNavigator's children and find the child which id is tabName.

     

    private function getChildByID(id:String, dataTabs:SuperTabNavigator):UIComponent { 

         var n:int = dataTabs.children().length;

         var gridPanel:UIComponent;

         for (var i:int = 0; i < n; i++) {

              gridPanel = dataTabs.getChildAt(i) as UIComponent;

              if(gridPanel.id == tabName) {

                  return gridPanel;

              }

         }

         return null;

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 4, 2013 5:36 PM   in reply to olegkon

    sorry about the dataTabs.children().length, it should be dataTabs.numChildren

     

    i wrote a example and it works right.

     

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                                            xmlns:ns="http://code.google.com/p/flexlib/"
                                            backgroundColor="0xFFFFFF" creationComplete="init()">
      
              <mx:Script>
                        <![CDATA[
                                  import mx.containers.Box;
                                  import mx.containers.VBox;
                                  import mx.controls.Alert;
                                  import mx.core.UIComponent;
      
                                  private function init():void {
                                            var tab:Box;
      
                                            for (var i:int = 0; i < 3; i++)
                                            {
                                                      tab = new Box();
                                                      tab.id = 'Tab' + i;
                                                      tab.label = 'Tab' + i;
                                                      dataTabs.addChild(tab);
                                            }
                                  }
      
                                  private function getChildById(id:String, tabs:SuperTabNavigator):UIComponent
                                  {
                                            var child:UIComponent;
                                            for (var i:int = 0, n:int = tabs.numChildren; i < n; i++)
                                            {
                                                      child = tabs.getChildAt(i) as UIComponent;
                                                      if (child.id == id)
                                                      {
                                                                return child;
                                                      }
                                            }
                                            return null;
                                  }
      
                                  protected function button1_clickHandler(event:MouseEvent):void
                                  {
                                            var child:UIComponent = getChildById('Tab2', dataTabs);
                                            Alert.show(child.id);
                                  }
      
                        ]]>
              </mx:Script>
      
              <ns:SuperTabNavigator id="dataTabs" height="90%" width="90%">
      
              </ns:SuperTabNavigator>
      
              <mx:Button label="Get Tab2" click="button1_clickHandler(event)"/>
    </mx:Application>
    
    
    

     

    Hope help for you.

     

    Huang

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points