1 Reply Latest reply on Feb 27, 2012 5:16 AM by Jakub Wojciechowski

    Reload viewstack child

    apurv123

      I am developing a flex application which has a master detail pages. The master page has a list of items in a datagrid and when the user clicks on an item the viewstack child is switched to display the details. I am also using a link bar to navigate back to the master view. However when the user clicks on a different item the child page does not get refreshed.

      What is the best way to reload the child view when the user clicks on a datagrid item?

        • 1. Re: Reload viewstack child
          Jakub Wojciechowski

          The easiest way is to have a bindable property in your detail View like:

          [Bindable]

          var user:UserType;

          and to bind all of your components to that user object, fe:

           

          <mx:Label id="userName" text="{user.name}" />

           

           

          And in your ViewStack:

           

          <mx:ViewStack>

               <SomeContainer>

                    <mx:DataGrid id="yourDataGrid" ... />

               </SomeContainer>

                <UserDetailView user="{yourDataGrid.selectedItem}"

          </mx:ViewStack>

           

          After changing the selection in your dataGrid, a new user object will be automatically binded to the view component.

           

          Of course you may consider a more complex solution with building a model layer containg selectedUser property, but the solution above should work ok.