3 Replies Latest reply on Nov 22, 2009 7:45 PM by jeeepU

    Max number in DataGrid


      I have one datagrid column called ID. I want to find the max number within that column and display it in a text box. Can someone provide some insight. Thank you

        • 1. Re: Max number in DataGrid
          ShankarFlex3 Level 2



          I can think of working out from the datagrid dataprovider.

          For ex: if the dataprovider is ArrayCollection, you could probably sort it and get the max value.

          • 2. Re: Max number in DataGrid
            jeeepU Level 1

            I am using this adobe tutorial here:



            Specifically, I am getting xml from this php:


            //return a list of all the users
            $Query = "SELECT * from users";
            $Result = mysql_query( $Query );

            $Return = "<users>";

            while ( $User = mysql_fetch_object( $Result ) )
            $Return .= "<user><userid>".$User->userid."</userid>
            $Return .= "</users>";
            mysql_free_result( $Result );
            print ($Return)


            This is based on an "all" query of the table. To get a max query I have to do things differently. Therefore, I was hoping to be able to do it within Flex.


            Can you suggest a specific way of how to get one xml variable from php and into a text box?

            • 3. Re: Max number in DataGrid
              ShankarFlex3 Level 2



              While you are iterating the resultSet, you could use logic to find out the Max userId.


              Define a variable maxUserId and if the current UserId is greater than maxUserId, then assign the current UserId to maxUserId, by the end of loop the maxUserId will hold the max value.


              Also define a xml tag <maxId>maxUserId</maxId> and you could use this tag in the text field.

              1 person found this helpful