4 Replies Latest reply on Dec 8, 2008 6:54 PM by ntsiii

    Passing recordID from datagrid component to another component

    azilaga
      Hi, I have an application that loads a datagrid via remoteobject. One of the columns loaded is a recordID. I'm trying to pass that recordID of the selected row from the datagrid to another component where I can use that recordID to drill down into the recordset. I've managed to select the recordID and pop it up in alert for verification, but I'm at a loss as to what to do from here codewise. Please help.

      Here's what I have so far:
        • 1. Re: Passing recordID from datagrid component to another component
          rtalton Level 4
          Can you use event.currentTarget.selectedIndex to work directly with the item in the dataprovider?
          • 2. Re: Passing recordID from datagrid component to another component
            azilaga Level 1
            I'm not sure I understand your suggestion. The selectedIndex doesn't give me the recordID that I need to shoot off another query into the database.

            Simplistically, what I'd like to do is this:

            - take the recordID that I'm displaying in the alert window
            - hold recordID in a variable someplace (url?)
            - switch states and load a different component
            - retrieve the recordID so I can place another remoteObject call to the database using the recordID

            Hopefully that makes a little more sense.

            Thanks for any help.
            • 3. Re: Passing recordID from datagrid component to another component
              rtalton Level 4
              If the "recordID" data is in your dataprovider, accessing this item through selectedIndex will allow you to manipulate it/use it at will directly in the dataprovider. Including getting at the "recordID" data and sending another query.
              Process flow:
              -User clicks on an item in the data grid.
              -Call function which accesses that item's data directly in the dataprovider:
              var item:Object;
              item = myDG.dataProvider.getItemAt(event.currentTarget.selectedIndex);
              trace(item.recordID); (also allows accessing other data in the item) OR
              Use your current code to get it: event.currentTarget.selectedItem.recordID.
              -Call an HTTPService (or whatever rpc you are using) and pass that "recordID" as a parameter within it.
              -In the rpc result handler (if data was returned), switch states and load new component with the data.
              • 4. Re: Passing recordID from datagrid component to another component
                ntsiii Level 3
                You can also get the id directly from target.selectedItem.recordID;

                Just saves a step. rtalton's suggestion is how I would do it also.

                If you have not used ViewStack, you should look at it as a replacement for States. it is often much simpler to work with.

                Tracy