4 Replies Latest reply on Apr 27, 2007 4:03 PM by AuroraCF

    Can not pass contactID to an other State (page)

    AuroraCF
      Hi,

      I am trying to pass the contactID from this grid to contactdetail page load from contact state. It's load fine but did not select the right record of contactdetail page. Any idea what I am mssing here?
      I do have funtion Edititem in the scripting block as below:
      private function EditItem(key:Object):void
      {
      var e:SelectionEvent;
      if( key == null )
      {
      e = new SelectionEvent("addItem", key);
      }
      else
      {
      e = new SelectionEvent("editItem", key);
      }
      this.dispatchEvent(e);
      }


      <mx:DataGrid doubleClickEnabled="true"
      id="contactsGrid" doubleClick="Application.application.currentState='Contact';EditItem(this.contactsGrid.se lectedItem.ContactID)"
      dataProvider="{contacts}"
      editable="false" width="100%" height="100%">
      <mx:columns>
      <mx:DataGridColumn dataField="ContactID" headerText="ID" width="30" />
      <mx:DataGridColumn dataField="FirstName" headerText="First Name" />
      <mx:DataGridColumn dataField="LastName" headerText="Last Name" />
      <mx:DataGridColumn dataField="Title" headerText="Title" />
      <mx:DataGridColumn dataField="Type" headerText="Type" />
      <mx:DataGridColumn dataField="Phone" headerText="Phone" />
      <mx:DataGridColumn dataField="Ext" headerText="Ext" />
      <mx:DataGridColumn dataField="MobilePhone" headerText="Mobile Phone" />
      <mx:DataGridColumn dataField="Email" headerText="Email" />
      </mx:columns>
      </mx:DataGrid>
        • 1. Re: Can not pass contactID to an other State (page)
          Rahul Mainkar Level 1
          Hi there,
          Everything looks fine in your prog.
          My suggestion is just a trial an error.

          Instead of passing (this.contactsGrid.selectedItem.ContactID), try to pass
          (this.contactsGrid.selectedItem)

          In your EditItem function , you can access this contact ID as key.ContactId.

          I am again saying just a trial and error.
          Hope it works.
          • 2. Re: Can not pass contactID to an other State (page)
            AuroraCF Level 1
            Rahul,

            Thank you for the suggestion, I gave it a shot but got this error:
            ReferenceError: Error #1069: Property ContactID not found on Number and there is no default value.
            at com.cfgenerated.views.masterdetail::Contact_master/::EditItem()

            I'm still pulling my hair out, this is alot harder the cf coding. I wonder how many ppl went through this difficulty or I just have not got grib on this flexy yet.
            • 3. Re: Can not pass contactID to an other State (page)
              Rahul Mainkar Level 1
              I have tried a similar way in my application and it worked.
              This error may have occured coz ContactId is not getting populated. Are you able to see the ID column perfectly populated?
              . One more debugging technique is to trace the results or put in alerts for displaying contactID value.This will help you to figure out wjether the value is getting populated in key or not.

              Ex:

              private function EditItem(key:Object):void
              {
              var e:SelectionEvent;
              Alert.show(Key.toString()); //new line
              if( key == null )
              {
              e = new SelectionEvent("addItem", key);
              }
              else
              {
              e = new SelectionEvent("editItem", key);
              }
              this.dispatchEvent(e);
              }



              If this doesnt show any proper output then try to make key as the type of ContactID (i.e string or Int etc)

              • 4. Re: Can not pass contactID to an other State (page)
                AuroraCF Level 1
                Rahul,

                I tried your suggestion, the contactID was pass, first click did not populate the firstname, last name but company name and some other fields. The second click (same record) populate all fields correctly. The 3rd click happen exactly the same as first click.

                Man, I tell you, this is driving me crazzzzy. Have you see any thing like this before?

                thanks again for your help.