4 Replies Latest reply on Sep 23, 2008 7:07 PM by Newsgroup_User

    Select a item in DataGrid

    zombiegx
      Im kind of a noob so I need help please :)
      How do you get the value or values of a selected row in a DataGrid when I click on it so I can print that value in a label (or just trace it as string)

      any hint would be great as I just can't seem to make this work

      look at my code, its quite simple

      thanks
        • 1. Re: Select a item in DataGrid
          ANewFlexUser
          If I'm reading your code right, you should be able to do this:

          lblPredio.text = dbGrid.selectedItem.data

          where data is the information you want to grab. In your case, it looks like it would be selectedItem.NumPredio SelectedItem reflects the entire selected object, not just the one element, so you have to specify. This also means you don't have to worry about sorting through all the seperate cells as individual cases; just grab the object and specify the correct element, and you're good to go.
          • 2. Re: Select a item in DataGrid
            zombiegx Level 1
            it worked!! it was so simple I feel kind of dumb haha

            thanks a lot
            • 3. Re: Select a item in DataGrid
              ANewFlexUser Level 1
              Glad I could help. Best of luck with your development.
              • 4. Re: Select a item in DataGrid
                Level 7

                "ANewFlexUser" <webforumsuser@macromedia.com> wrote in message
                news:gbbajp$t2t$1@forums.macromedia.com...
                > If I'm reading your code right, you should be able to do this:
                >
                > lblPredio.text = dbGrid.selectedItem.data
                >
                > where data is the information you want to grab. In your case, it looks
                > like
                > it would be selectedItem.NumPredio SelectedItem reflects the entire
                > selected
                > object, not just the one element, so you have to specify. This also means
                > you
                > don't have to worry about sorting through all the seperate cells as
                > individual
                > cases; just grab the object and specify the correct element, and you're
                > good to
                > go.

                The event object that comes in the itemClick function parameter should give
                you enough information where you can get the column.