4 Replies Latest reply on Sep 8, 2011 2:36 PM by madhooper

    Quick Question about Air

    madhooper Level 1

      I'm displaying my file structure in a tree. When an item in the tree is selected I update the view in the datagrid to display what's in the directory. I'd like the user to be able to change from the datagrid view to a tilelist view. Does anyone know how this is done?

      <?xml version="1.0" encoding="utf-8"?> 
      <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"> 
           <mx:HDividedBox> 
           <mx:FileSystemTree id="tree"  
               width="200" height="100%" 
               directory="{File.documentsDirectory}" 
               enumerationMode="directoriesOnly" 
               change="dataGrid.directory = File(tree.selectedItem);"/>     
           <mx:FileSystemDataGrid id="dataGrid"  
               width="100%" height="100%" 
               directory="{File.documentsDirectory}"/> 
           </mx:HDividedBox> 
      </mx:WindowedApplication>

        • 1. Re: Quick Question about Air
          Daniel Pride Level 1

          If the datagrid and the tilelist share the same dataprovider then you can assign the datagrid to one state (say "Grid") and the tilelist to another state (say "List) then swithing states back and for with a currentState='Grid'  or currentState='List" would do the trick.

           

          Not sure about some of your MXML code tho, specifically the stuff like datagrid.directory ? You need to rethink that a bit I think.

           

          Just concentrate on setting up your page to first display one, then assign it to a state, then work on the other and you accomplish the switch by changing states back and forth.

           

          Note a tilelist and a datagrid are components and one does not contain the other without code that's way beyond  you and me

           

          Hope this helps

          Dan Pride

          • 2. Re: Quick Question about Air
            madhooper Level 1

            Thanks

             

            Currently i'm able to display my data in a datagrid using "file.documentsDirectory" That's works fine but my user wants to be able to switch his view from datagrid, tile view & list view.

             

            Air has a simple way to display the users current directory in a datagrid but i can't find an simple way to display the users current directory in a tile list.

            • 3. Re: Quick Question about Air
              Daniel Pride Level 1

              Try casting it as the appropriate datatype for the dataprovider property

              • 4. Re: Quick Question about Air
                madhooper Level 1

                thanks for your help. the solution was simple. I wrote a method that set the "directory" property of my 3 views everytime a "change event" was triggered on my filesystemtree component.