3 Replies Latest reply on Sep 5, 2008 7:23 AM by @logg57

    Between 2 viewStates

    @logg57
      A MenuBar in the main application manage different viewStates.

      -In my 'userState', I call a MXML component named manageUsers.mxml, based on a Canvas.

      -In this Canvas, I display data in an AdvancedDataGrid with HTTPService via a PHP and MySQL. These request provide my table tbl_login (informations of the users, such as login, mdp, type, etc..)

      -Data are grouped with a GroupingCollection in order to group them by 'type'. (in AS3)
      -->It works correctly that's fine, i've a beautiful ADG that display my users informations ordered by type (admin, simpleUser..) with a small icon of a file.

      -One button REFRESH on the bottom of the Canvas enable to call my PHP file another time in order to reload and refresh the data when i change some values in my tbl_users. It works correctly too.

      BUT, If I change the currentState with my MenuBar from an other viewState (for example 'homeState'), when I go back to 'userState', the ADG display only the data in ligne, without grouping them by type.

      BUT, when I call my function to reload the data from my PHP file with my REFRESH button, the grouping works as well as in the first creationComplete of the MXML component.


      I don't know if i made a mistake in my definition or if there is a problem with the maintain of the state between 2 viewStates.
      How can I do to call my REFRESH function in the MXML component from the main application when I click my menuBar?

      Thank you if you have some elements or suggestions to help me..
      Alexandre(newbie)
        • 1. Re: Between 2 viewStates
          @logg57 Level 1
          I have a solution : to call my HTPService from the main application with : nameOfMyMXMLComponent.MyHTTPServiceID.send()
          It works.. BUT... if you have a better solution...
          • 2. Re: Between 2 viewStates
            Level 7

            "@logg57" <webforumsuser@macromedia.com> wrote in message
            news:g8vegn$g0p$1@forums.macromedia.com...
            >A MenuBar in the main application manage different viewStates.
            >
            > -In my 'userState', I call a MXML component named manageUsers.mxml, based
            > on a
            > Canvas.
            >
            > -In this Canvas, I display data in an AdvancedDataGrid with HTTPService
            > via a
            > PHP and MySQL. These request provide my table tbl_login (informations of
            > the
            > users, such as login, mdp, type, etc..)
            >
            > -Data are grouped with a GroupingCollection in order to group them by
            > 'type'.
            > (in AS3)
            > -->It works correctly that's fine, i've a beautiful ADG that display my
            > users
            > informations ordered by type (admin, simpleUser..) with a small icon of a
            > file.
            >
            > -One button REFRESH on the bottom of the Canvas enable to call my PHP file
            > another time in order to reload and refresh the data when i change some
            > values
            > in my tbl_users. It works correctly too.
            >
            > BUT, If I change the currentState with my MenuBar from an other viewState
            > (for
            > example 'homeState'), when I go back to 'userState', the ADG display
            > only the
            > data in ligne, without grouping them by type.
            >
            > BUT, when I call my function to reload the data from my PHP file with my
            > REFRESH button, the grouping works as well as in the first
            > creationComplete of
            > the MXML component.
            >
            >
            > I don't know if i made a mistake in my definition or if there is a problem
            > with the maintain of the state between 2 viewStates.
            > How can I do to call my REFRESH function in the MXML component from the
            > main
            > application when I click my menuBar?
            >
            > Thank you if you have some elements or suggestions to help me..
            > Alexandre(newbie)
            >
            > <?xml version="1.0" encoding="utf-8"?>
            > <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml"
            > initialize="initApp()">
            > <mx:HTTPService id="dataUsersRPC"
            > url=" http://www.protocole-ecn.com/protoTools/users/usersXML.php"
            > resultFormat="object" result="onResult(event)"/>
            >
            > <mx:Script>
            > <![CDATA[
            > import mx.rpc.events.ResultEvent;
            > import mx.collections.ArrayCollection;
            > import mx.collections.XMLListCollection;
            > import mx.collections.Grouping;
            > import mx.collections.GroupingCollection;
            > import mx.collections.GroupingField;
            > [Bindable]
            > private var dataUsers:ArrayCollection;
            >
            > private function initApp():void{
            > this.dataUsersRPC.send();
            >
            > }
            > private function onResult(event:ResultEvent):void{
            > this.dataUsers=event.result.informationsUsers.users;
            > var myGroupColl:GroupingCollection=new GroupingCollection();
            > myGroupColl.source=this.dataUsers;
            > var group:Grouping=new Grouping();
            > var gf:GroupingField=new GroupingField("type");
            > group.fields=[gf];
            > myGroupColl.grouping=group;
            > myGroupColl.refresh();
            > myDG.dataProvider=myGroupColl;
            > }
            >
            >
            > public function refreshDG():void{
            > this.dataUsersRPC.send();
            >
            > }
            > ]]>
            > </mx:Script>
            >
            > <mx:VBox width="100%" height="100%">
            > <mx:HBox width="100%" height="100%">
            > <mx:AdvancedDataGrid id="myDG" width="100%" height="100%"
            > dataProvider="{dataUsers}" >

            ^^^^^^^^^You're binding to the flat ArrayCollection, but when you call the
            send() method, it reruns your onResult, which properly assigns the
            dataProvider as myGroupColl.

            HTH;

            Amy


            • 3. Re: Between 2 viewStates
              @logg57 Level 1
              Thank you Amy ;