4 Replies Latest reply on Jan 6, 2011 5:53 AM by jfb00

    Advanced datagrid question

    jfb00 Level 3

      Hi All,

      I have an ADG displaying items in groups showing totals for each group using:

       

                private function summFunc(cursor:IViewCursor, dataField:String, operation:String):Number{
                      var sumAll:Number = 0;
                      while (!cursor.afterLast)
                      {
                          if (dataField == "Amount")
                              sumAll += Number(parseFloat(cursor.current["Amount"]));
                          cursor.moveNext();
                      }
                      return sumAll;
                  }
      
                <mx:dataProvider>
                  <mx:GroupingCollection id="groupedData" source="{acSampleADG}" >
                      <mx:Grouping>
                          <mx:GroupingField name="Series" >
                              <mx:summaries>
                                  <mx:SummaryRow summaryPlacement="last" summaryObjectFunction="summObjFunc">
                                      <mx:fields>
                                          <mx:SummaryField dataField="Amount" summaryFunction="summFunc" />
                                      </mx:fields>
                                  </mx:SummaryRow>
                              </mx:summaries>
                          </mx:GroupingField>
                      </mx:Grouping>
                  </mx:GroupingCollection>
              </mx:dataProvider>
      

       

      Amount column is editable. If I change the value for an item the total for the group is not updating.

      How can I refresh that value?

      Thanks

       

      Johnny

        • 1. Re: Advanced datagrid question
          Sree_D Level 2

          I think calling groupedData.refresh() in itemEditEnd event of ADG would work

          • 2. Re: Advanced datagrid question
            jfb00 Level 3

            Thanks for you reply and help.

            It doesn't work, i got and error:

            Error #1023: Stack overflow occurred.

            Any other idea?

            Rgds

             

            Johnny

            • 3. Re: Advanced datagrid question
              jfb00 Level 3

              I figure out to skip the error in my ITEM_EDIT_END event.

              Now if I use groupedData.refresh() it puts the old values back. Is this a bug?

              Any ideas?

               

              Johnny

               

              Here is my fuction for  ITEM_EDIT_END event.

               

              private function update_ADG_values(event:AdvancedDataGridEvent):void{
                  var grid:AdvancedDataGrid = event.target as AdvancedDataGrid;
              
                  if(event.dataField=="Amount"){
                      acSampleADG.refresh();
                      myADG.validateNow();
                      var myEditor:TextInput = TextInput(event.currentTarget.itemEditorInstance);
                      var newVal:Number = parseFloat(myEditor.text.replace(",",""));
                      var oldVal:Number = Number(event.itemRenderer.data[event.dataField]); 
                      if (event.reason == DataGridEventReason.CANCELLED || event.reason == DataGridEventReason.OTHER || oldVal == newVal) {
                          event.preventDefault();
                          grid.destroyItemEditor();
                          return;
                      }
                      groupedData.refresh();
                  }
              }
              
              • 4. Re: Advanced datagrid question
                jfb00 Level 3

                I got it. It is good to talk alone here

                groupedData.refresh(true);

                True fixed all.

                Rgds

                 

                Johnny