1 Reply Latest reply on Apr 7, 2009 3:38 AM by nikos101

    arbitrary values in the summary row

    irislpc

      I populated my advancedDataGrid with flat arrayCollection. I have no problem grouping the data. However, I was wondering if it is possible to set an arbitrary values in the summary row. Is it possible to display a pre-defined value in the summary field? Here are my codes.

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

      <mx:Script>
        <![CDATA[
         import mx.collections.ArrayCollection;
         import mx.utils.ObjectUtil;


         [Bindable]
         private var dpFlat:ArrayCollection = new ArrayCollection([
           {version:"V8,2WD", spot:"Engine Major", order:"01",
               year_99:"4", year_00:"5", year_01:"0", year_02:"4", year_03:"5",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
           {version:"V8,2WD", spot:"Engine Minor", order:"02",
               year_99:"4", year_00:"3", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
           {version:"V8,2WD", spot:"Engine Cooling", order:"03",
               year_99:"4", year_00:"3", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
           {version:"V8,2WD", spot:"Transmission Major", order:"04",
               year_99:"4", year_00:"3", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
           {version:"V8,2WD", spot:"Transmission Minor", order:"05",
               year_99:"4", year_00:"3", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
           {version:"V8,2WD", spot:"Drive System", order:"06",
               year_99:"4", year_00:"3", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
           {version:"V8,2WD", spot:"Fuel System", order:"07",
               year_99:"4", year_00:"3", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
           {version:"V8,2WD", spot:"Electrical System", order:"08",
               year_99:"4", year_00:"3", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
              {version:"V8,2WD", spot:"Climate System", order:"09",
               year_99:"4", year_00:"3", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
              {version:"V8,2WD", spot:"Suspension", order:"10",
               year_99:"4", year_00:"3", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
              {version:"V8,2WD", spot:"Brakes", order:"11",
               year_99:"4", year_00:"3", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
              {version:"V8,2WD", spot:"Exhaust", order:"12",
               year_99:"4", year_00:"3", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
              {version:"V8,2WD", spot:"Paint/Trim", order:"13",
               year_99:"4", year_00:"3", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
              {version:"V8,2WD", spot:"Squeaks & Rattles", order:"14",
               year_99:"4", year_00:"3", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
              {version:"V8,2WD", spot:"Body Hardware", order:"15",
               year_99:"4", year_00:"3", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
              {version:"V8,2WD", spot:"Power Equip.", order:"16",
               year_99:"4", year_00:"3", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
              {version:"V8,2WD", spot:"Audio System", order:"17",
               year_99:"2", year_00:"3", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
           {version:"V6,2WD", spot:"Engine Major",
               year_99:"1", year_00:"1", year_01:"2", year_02:"4", year_03:"5",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
           {version:"V6,2WD", spot:"Engine Minor",
               year_99:"5", year_00:"3", year_01:"4", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
           {version:"V6,2WD", spot:"Engine Cooling",
               year_99:"4", year_00:"4", year_01:"5", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
           {version:"V6,2WD", spot:"Transmission Major",
               year_99:"3", year_00:"3", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
           {version:"V6,2WD", spot:"Transmission Minor",
               year_99:"2", year_00:"4", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
           {version:"V6,2WD", spot:"Drive System",
               year_99:"4", year_00:"2", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
           {version:"V6,2WD", spot:"Fuel System",
               year_99:"2", year_00:"1", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
           {version:"V6,2WD", spot:"Electrical System",
               year_99:"4", year_00:"2", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
              {version:"V6,2WD", spot:"Climate System",
               year_99:"3", year_00:"5", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
              {version:"V6,2WD", spot:"Suspension",
               year_99:"3", year_00:"4", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
              {version:"V6,2WD", spot:"Brakes",
               year_99:"4", year_00:"3", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
              {version:"V6,2WD", spot:"Exhaust",
               year_99:"4", year_00:"3", year_01:"2", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
              {version:"V6,2WD", spot:"Paint/Trim",
               year_99:"4", year_00:"3", year_01:"5", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
              {version:"V6,2WD", spot:"Squeaks & Rattles",
               year_99:"4", year_00:"3", year_01:"4", year_02:"3", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
              {version:"V6,2WD", spot:"Body Hardware",
               year_99:"4", year_00:"3", year_01:"0", year_02:"5", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
              {version:"V6,2WD", spot:"Power Equip.",
               year_99:"4", year_00:"5", year_01:"0", year_02:"4", year_03:"3",
               year_04:"5", year_05:"0", year_06:"5", year_07:"0", year_08:"0"},
              {version:"V6,2WD", spot:"Audio System",
               year_99:"3", year_00:"3", year_01:"0", year_02:"4", year_03:"3",
               year_04:"1", year_05:"0", year_06:"3", year_07:"0", year_08:"0"}
         ]);
        
         private function orderCompareFunction(a:Object, b:Object):int
         {
             return ObjectUtil.stringCompare(a.order,
                                             b.order);
         }


        ]]>
      </mx:Script>

      <mx:AdvancedDataGrid id="myADG"
              width="100%" height="100%"
              defaultLeafIcon="{null}"
              initialize="gc.refresh();">       
              <mx:dataProvider>
                  <mx:GroupingCollection id="gc" source="{dpFlat}">
                      <mx:Grouping>
                          <mx:GroupingField name="version" compareFunction="orderCompareFunction">
                          </mx:GroupingField>
                      </mx:Grouping>
                  </mx:GroupingCollection>
              </mx:dataProvider>       
             
              <mx:columns>
                  <mx:AdvancedDataGridColumn dataField="spot"
                      headerText=""/>
                  <mx:AdvancedDataGridColumn dataField="year_99"
                      headerText="99"/>
                  <mx:AdvancedDataGridColumn dataField="year_00"
                      headerText="00"/>
                  <mx:AdvancedDataGridColumn dataField="year_01"
                      headerText="01"/>
                  <mx:AdvancedDataGridColumn dataField="year_02"
                      headerText="02"/>
                  <mx:AdvancedDataGridColumn dataField="year_03"
                      headerText="03"/>
                  <mx:AdvancedDataGridColumn dataField="year_04"
                      headerText="04"/>
                  <mx:AdvancedDataGridColumn dataField="year_05"
                      headerText="05"/>
                  <mx:AdvancedDataGridColumn dataField="year_06"
                      headerText="06"/>
                  <mx:AdvancedDataGridColumn dataField="year_07"
                      headerText="07"/>
                  <mx:AdvancedDataGridColumn dataField="year_08"
                      headerText="08"/>
              </mx:columns>
         </mx:AdvancedDataGrid>


      </mx:Application>

        • 1. Re: arbitrary values in the summary row
          nikos101 Level 2

          Hi welcome to the forum, I hope you find lots of help here and we look forward to your contributions as well

           

          In regards to your question I would recommend that youuse a summaryFunction

           

          eg

           

          <mx:SummaryField label="totalGBP_Eq" summaryFunction="countGPB_4_Ref"/>

           

                  private function countGPB_4_Ref(iterator:IViewCursor, dataField:String, operation:String):Object
                      {
                          var totalGBP:Number=0;
                          while(!iterator.afterLast)
                          {
                              totalGBP+=iterator.current.amount / iterator.current.rate;
                              iterator.moveNext();
                          }
                          return totalGBP;
                      }

           

           

           

           

           

          Hope this helps

           

          Best regards

           

          Nikos