9 Replies Latest reply on Aug 13, 2007 9:49 AM by rbetieh

    Performance of  ADG Tied to number of Columns?

    rbetieh Level 1
      Hi All,

      I was wondering if there is a correlation between the time it takes for an ADG to update itself after data changes and the number of columns. I want to know in case its just my bad code :-). As an example, I notice that the ADG is much slower under 31 columns than 15 for this simple example. I am a beginner at this so I assume I dont know what I am doing, but the speed difference is an order of magnitude different.

      <mx:AdvancedDataGrid xmlns:mx=" http://www.adobe.com/2006/mxml" rowHeight="25" sortItemRenderer="SortItemHider"
      creationComplete="init()" allowMultipleSelection="true" selectionMode="singleCell" itemClick="setStart(event)" xmlns:local="*" >

      <mx:columns>
      <mx:AdvancedDataGridColumn dataField="task" id="task" headerText="task" width="60" textAlign="center" resizable="true" />
      </mx:columns>

      ...

      private function initColumns():void //This function creates a bunch of dynamic columns and adds them to the adg
      {
      var test1:Array = this.columns;
      var test2:ArrayCollection = new ArrayCollection(test1);
      test2.removeAll();
      for(var index:int = 0; index < this.columns.length; index++)
      {
      test2.addItem(this.columns[index]);
      }
      defaultColumns = test2.length - 1;
      for(var x:int = 0; x < MAX_COLS; x++)
      {
      var newColumn:AdvancedDataGridColumn = new AdvancedDataGridColumn("day"+(x+1));
      newColumn.dataField = "day"+(x+1);
      newColumn.setStyle("textAlign", "center");
      var day:Number = todaysDate.getDate();
      newColumn.headerText = String(x);
      test2.addItem(newColumn);
      }
      this.columns = test1;
      }

      ...

      private function setStart(event:ListEvent):void //when a cell that is not the first is clicked, this will set data into the adg
      {
      var task:String = event.itemRenderer.data.task;

      var selectedRow:int = dataArray.getItemIndex(event.itemRenderer.data);
      var selectedItem:Object = dataArray[selectedRow];

      var totalHours:int = selectedItem.unscheduled;
      selectedItem.unscheduled = 0;
      var startDay:int = this.selectedColumnIndex - defaultColumns;
      if(startDay > 0 && selectedRow != -1)
      {
      var HoursPerDay:int = 8;
      var dailyHours:int = totalHours / HoursPerDay;
      var leftoverHours:int = totalHours % HoursPerDay;
      var days:int = dailyHours + (leftoverHours != 0 ? 1 : 0);
      var endDay:int = startDay + days;
      selectedItem.start = startDay;
      var columnName:String;
      for( var index:int = startDay; index < endDay; index++)
      {
      columnName = "day"+index;
      if(index < this.columns.length)
      {
      if(index == endDay-1 && leftoverHours > 0)
      {
      selectedItem[columnName] = leftoverHours;
      return;
      }
      selectedItem[columnName] = HoursPerDay;
      }
      }
      }
      }
      }
        • 1. Re: Performance of  ADG Tied to number of Columns?
          sameerb Level 1
          Hi,
          Can you post the whole sample with the dataProvider so that we can test it at our end.

          Thanks,
          Sameer
          • 2. Re: Performance of  ADG Tied to number of Columns?
            rbetieh Level 1
            Hi Sameer,

            Here is the full app + data source, I put the data in its own XML

            Reducing the number of rows/columns will increase performance,


            Data... Work.xml

            <?xml version="1.0" encoding="utf-8"?>
            <work>
            <job>
            <Task>Task1</Task>
            <name>Jim</name>
            <hours>16</hours>
            <start>6</start>
            </job>
            <job>
            <Task>Task2</Task>
            <name>Jim</name>
            <hours>28</hours>
            <start>5</start>
            </job>
            <job>
            <Task>Task3</Task>
            <name>Jim</name>
            <hours>12</hours>
            <start>3</start>
            </job>
            <job>
            <Task>Task1</Task>
            <name>Fred</name>
            <hours>20</hours>
            <start>1</start>
            </job>
            <job>
            <Task>Task2</Task>
            <name>Fred</name>
            <hours>8</hours>
            <start></start>
            </job>
            <job>
            <Task>Task3</Task>
            <name>Fred</name>
            <hours>5</hours>
            <start></start>
            </job>
            <job>
            <Task>Task1</Task>
            <name>Bob</name>
            <hours>21</hours>
            <start>1</start>
            </job>
            <job>
            <Task>Task2</Task>
            <name>Bob</name>
            <hours>9</hours>
            <start></start>
            </job>
            <job>
            <Task>Task3</Task>
            <name>Bob</name>
            <hours>7</hours>
            <start></start>
            </job>
            </work>


            .....


            APP

            .....
            • 3. Re: Performance of  ADG Tied to number of Columns?
              sameerb Level 1
              Hi,
              Thanks for posting the sample.

              You are using two SummaryRows with 31 fields each.

              So, every time you change a property in the data item, the Summaries will be re-computed to reflect that change.
              And the GroupingCollection have to calculate the Summaries for 2 x 31 fields.

              This is the reason for the updates to be slow.

              Thanks,
              Sameer
              • 4. Re: Performance of  ADG Tied to number of Columns?
                dolinja
                Hi Sameer,

                I am also having major problems with GroupingCollection performance. I posted here two weeks ago with no replies. Could you please check out this thread? Thank you so much!

                http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=72&catid=651&threadid =1286623&highlight_key=y&keyword1=performance

                Jason
                • 5. Re: Performance of  ADG Tied to number of Columns?
                  rbetieh Level 1
                  Hi Sameer,

                  Each summary row displays different data. Is there some way to have the second summary row calculate from the result of the first instead of from the data in the adg?
                  • 6. Re: Performance of  ADG Tied to number of Columns?
                    rbetieh Level 1
                    Hi,

                    I ran a quick test here is what I did.

                    I opened the first grouping and clicked on one of the cells. And time the response between the screen updated and the cells. (5 seconds)

                    I removed a Summary row and re-timed (4 seconds)

                    I removed all the dynamicly createed summary fields and re-timed (4 seconds)

                    I removed all summaries and retimed (3 seconds)

                    Is it possible that each cell changed in the setStartDate is causing a callback trigger like dataChange() and this is slowing me down?
                    • 7. Re: Performance of  ADG Tied to number of Columns?
                      sameerb Level 1
                      Hi,

                      Everytime a property is changed, an event is dispatched and the collectionChangeHandler gets invoked to take the respective changes.

                      And in your sample there are various properties which are changing.
                      The method cleanHours() is deleting 31 properties.

                      Eah property change will trigger the summaries to be re-computed.

                      Thanks,
                      Sameer
                      • 8. Re: Performance of  ADG Tied to number of Columns?
                        rbetieh Level 1
                        Thanks for the information Sameer.

                        So then what I really want to do is have it commit all the updates all at once instead of through a loop. Does this make sense?

                        1) create a copy of my data object in the array collection
                        2) change all the data elements as necessary
                        3) replace the array collection row with the new data object.

                        Is this possible?
                        • 9. Re: Performance of  ADG Tied to number of Columns?
                          rbetieh Level 1
                          Hi,

                          Ive managed to make the program much faster by using a labelfunction that calculated whether or not to put data in one of the dynamic 31 columns instead of calculating and setting that data up-front. Then I created summaries that do the same thing for the summation. The problem is there is no documentation on the summaryObject so I cant see the data elements available to me to know where the calculated summary is. In the following function.

                          private function showData(dataObj:Object, column:AdvancedDataGridColumn):String
                          {
                          if(dataObj is SummaryObject)
                          {
                          return String(dataObj.summary);
                          }

                          I need to know what field I ought to be getting. The result of that is that my summaries read "undefiend"

                          Also, I think I should be able to use this to calculate one summary based on the result of another summary. What do you guys think?

                          Here is the updated code.