6 Replies Latest reply on Oct 1, 2010 3:52 PM by ssardar

    DataGrid Question

    ssardar Level 1

      How do I get one column in the datagrid to display it's index number in the underlying ArrayCollection?

        • 1. Re: DataGrid Question
          Rajeshwar Gaini

          Can you elaborate with an example ?

          • 2. Re: DataGrid Question
            ssardar Level 1

            I have a datagrid with

             

            200 items (rows), and 4 columns for the elements of the objects in the ArrayCollection

             

            How, in MXML, do I get the bound object to fill a 5th column with it's index position so I will have a sequence number in my 5th column.

             

            Basically this is a template creation, where each sequence number will identify a positional value in the Grid generated from this template.  I need to do it this way as the setup for this screen allows users to move items in this grid up and down using buttons.  I just need to display them in the GRID itself so please don't tell me I can get them when I process as I know this already, and plan to do that, but I also need to display them so the user does not get confused.  So I need to know what to bind to the datafield="{}" attribute in row 5 of my grid here.

             

            ProjectIDEventIDTemplateIDTemplateItemSeq
            0
            1
            2
            3
            4
            5
            6
            7
            8
            9
            10
            11
            12
            13
            14
            15
            16
            17
            18
            19

            • 3. Re: DataGrid Question
              Flex harUI Adobe Employee

              It will depend on whether the sequence number stays with the data if it is

              moved or not.

              • 4. Re: DataGrid Question
                ssardar Level 1

                No I want the sequence numbers to stay the same, just basicall display the row number.

                So as items move up and down the seq number merely displays the row number.

                 

                 

                I do an update to the seqnumber in the DB when the save button is hit at the bottm of the screen.

                • 5. Re: DataGrid Question
                  Flex harUI Adobe Employee

                  Try using any valid dataField, then set labelFunction to a function that

                  takes the data and calls getItemIndex on the dataProvider.

                   

                  If you have tons of rows, that might get slow as getItemIndex does a linear

                  search.  Then your options would be to keep those indexes in the

                  dataprovider items or an associated table, or use a custom item renderer.

                  I'm pretty sure I've already shown someone else how to create such a

                  renderer so check the forum archives.

                  • 6. Re: DataGrid Question
                    ssardar Level 1

                    I don't have that many rows, in actual usage it will not be more than 123.  Let me give this labelfunction

                    approach a try, I already marked it correct, as you answers usually are.  Thanks.