4 Replies Latest reply on Aug 7, 2009 2:58 PM by sboja85

    problem with viewstack




      I have a question about viewstack.


      I have created inside my ViewStack, two Canvas. One is for showing my data in datagrid and second is for editing. After I click into datagrid I am redirecting user to second canvas calling this function:


      public function goToLdodaj():void
          myLinki.selectedChild = Ldodaj;
          name_edit.text = mainDatagrid.selectedItem.name;
          addr_edit.text = mainDatagrid.selectedItem.addr;
          desc_edit.text = mainDatagrid.selectedItem.desc;   


      Problem is that when I do it and for example I click on any row... I am redirected, but my three imputs are empty.


      When I go back to my canvas and click again edit On other row... I now can see result but from my first click.


      I would be greatfull for information what I do wrong.
      Thanks in advance for any help.

        • 1. Re: problem with viewstack

          Call them this way:


          name_edit.text = mainDatagrid.selectedItem.name;
          addr_edit.text = mainDatagrid.selectedItem.addr;
          desc_edit.text = mainDatagrid.selectedItem.desc; 


          // And then switch the active page

          myLinki.selectedChild = Ldodaj;

          • 2. Re: problem with viewstack
            sboja85 Level 1

            I try this, but nothing happen

            • 3. Re: problem with viewstack
              Gregory Lafrance Level 6

              I created this example code to answer your question.


              If this post answers your question or helps, please mark it as such.


              <?xml version="1.0" encoding="utf-8"?>
              <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                    import mx.events.ListEvent;
                    import mx.events.ItemClickEvent;
                    import mx.collections.ArrayCollection;
                    [Bindable] private var ac:ArrayCollection = new ArrayCollection([
                      {name: "Bob Smith", addr: "New York", desc: "Main contact at Firegem, Inc."},
                      {name: "Tim Casey", addr: "Boston", desc: "Friend from school"},
                      {name: "Jon Markos", addr: "Miami", desc: "My teacher"}

                    public function goToLdodaj(evt:ListEvent):void{
                      myLinki.selectedChild = Ldodaj;
                      name_edit.text = evt.currentTarget.selectedItem.name;
                      addr_edit.text = evt.currentTarget.selectedItem.addr;
                      desc_edit.text = evt.currentTarget.selectedItem.desc;   
                <mx:ViewStack id="myLinki" creationPolicy="all">
                  <mx:Canvas id="mainData">
                    <mx:DataGrid id="mainDatagrid" dataProvider="{ac}"
                        <mx:DataGridColumn dataField="name" width="100"/>
                        <mx:DataGridColumn dataField="addr" width="100"/>
                        <mx:DataGridColumn dataField="desc" width="200"/>
                  <mx:Canvas id="Ldodaj">
                      <mx:FormItem label="Name:">
                        <mx:TextInput id="name_edit" top="10" width="200"/>
                      <mx:FormItem label="Addr:">
                        <mx:TextInput id="addr_edit" top="40" width="200"/>
                      <mx:FormItem label="Desc:">
                        <mx:TextInput id="desc_edit" top="70" width="200"/>

              • 4. Re: problem with viewstack
                sboja85 Level 1

                I'm very gratefull for You help It works!