1 Reply Latest reply on Jun 3, 2011 2:15 AM by harihisu

    Calculate percentage of two summary row in AdvancedDataGrid




      I have an advanced datagrid with 4 Hierarchical levels. I am using the "SUM" function of the summaryOperation to sum all the relevant data for a particular node. Now I want to calculate the percentage of these two summarized row. How can I do that? I tried to use the ISummaryCalculator interface. But its unable to fetch the summarized data. It just works on the dataprovider. I have tried really hard. But I couldn't find any solution. Please help me with this issue. I am posting an example below. I have these summarized values for cost and budget using the sum method in the summaryoperation. I want to calculate percentage on each level. The data for the leaves, I already have. I am summarizing the data above that. Please help me. Thank you very much.


      GroupName                    Cost              Budget              Percentage

      Node1                              5000          8000                       

           Node2                         5000          8000

                Node3.1                 2000          4000

                     Leaf1                  500          1000

                     Leaf2                1500          3000

                Node3.2                 3000          5000

                    Leaf                  3000          5000

        • 1. Re: Calculate percentage of two summary row in AdvancedDataGrid

          I suggest that you should not embed the dataProvider directly to the MXML code. Instead, using Actionscript code to pre-process it before displaying. Like my example below, when you change the data, actually invoke set method of adgData. The input data will be processed in this set method and stored to local variable processedData. The [Bindable] metadata tag will notify to AdvancedDataGrid when there is any invocation to set method of adgData, then this AdvancedDataGrid just simply calls get method of adgData. Hope this helps.




                    private var rawData:Array = [];

                    private var processedData:Array = [];

                    private var data1:Array = [{cost:1000, budget:1500, percentage:0}];

                    private var data2:Array = [{cost:200, budget:1000, percentage:0}];




                    public function get adgData(): Array {

                         return processedData;


                    public function set adgData( value: Array ): void {

                         rawData = value;

                         if ( rawData != null && rawData.length != 0 ) {

                              // do your calculations here

                              // compute your sum, then the percentages by yourself





          <mx:AdvancedDataGrid id="adg"  designViewDataType="tree" dataProvider="{adgData}">