4 Replies Latest reply on Nov 19, 2008 12:52 PM by Newsgroup_User

    Bind value to sum of ArrayCollection values?

    john isaacks Level 1
      ok so if I had a DataGrid containing the ArrayCollection shown. How can I bind a label to show the sum of the product_price field?

      Is this possible?

      Thanks!
        • 1. Re: Bind value to sum of ArrayCollection values?
          john isaacks Level 1
          well I could probably write a function that adds up the product_price's but I dont think there is a way that you can make the return value of a function bindable is there?


          well is there an event listener I can listen for that will let me know whenever an item has been added or removed from a DataGrid then I can update the sum value?


          Thanks!
          • 2. Re: Bind value to sum of ArrayCollection values?
            Level 7

            "john isaacks" <webforumsuser@macromedia.com> wrote in message
            news:gf1mjc$i1o$1@forums.macromedia.com...
            > well I could probably write a function that adds up the product_price's
            > but I
            > dont think there is a way that you can make the return value of a function
            > bindable is there?
            >
            >
            > well is there an event listener I can listen for that will let me know
            > whenever an item has been added or removed from a DataGrid then I can
            > update
            > the sum value?

            You could extend ArrayCollection and add another property, or you create a
            custom class that has an ArrayCollection as one property and the sum as a
            different property.

            HTH;

            Amy


            • 3. Re: Bind value to sum of ArrayCollection values?
              john isaacks Level 1


              You could extend ArrayCollection and add another property, or you create a
              custom class that has an ArrayCollection as one property and the sum as a
              different property.

              HTH;

              Amy





              Thank you Amy that worked...Here is the class if anyone is interested
              • 4. Re: Bind value to sum of ArrayCollection values?
                Level 7

                "john isaacks" <webforumsuser@macromedia.com> wrote in message
                news:gg1po6$k24$1@forums.macromedia.com...
                >
                > You could extend ArrayCollection and add another property, or you create a
                > custom class that has an ArrayCollection as one property and the sum as a
                > different property.
                >
                > HTH;
                >
                > Amy
                >
                >
                >

                >
                > Thank you Amy that worked...Here is the class if anyone is interested
                >

                Cool :-). Thanks.