2 Replies Latest reply on Nov 12, 2010 10:24 AM by jfb00

    Opening Groups and Sub Groups of AdvancedDataGrid programatically

    bastughughu

      I have an AdvancedDataGrid. There are Groupings inside the Grid. I have the Grouping collection as follows:

       

                  <mx:dataProvider>
                          <mx:GroupingCollection id="groupAccountType" source="{modelLocator.accountTypeArrColl}" >
                              <mx:Grouping>
                                  <mx:GroupingField name="accountType" >
                                              <mx:SummaryRow summaryPlacement="group">
                                                         <mx:SummaryField dataField="accountBalance" operation="SUM"/>
                                                         <mx:SummaryField dataField="count" operation="COUNT" />
                                                 </mx:SummaryRow>
                                      </mx:GroupingField>
                                      <mx:GroupingField name="order" >
                                              <mx:SummaryRow summaryPlacement="group">
                                                         <mx:SummaryField dataField="accountBalance" operation="SUM"/>
                                                         <mx:SummaryField dataField="count" operation="COUNT" />
                                                 </mx:SummaryRow>
                                      </mx:GroupingField>
                              </mx:Grouping>
                          </mx:GroupingCollection>
                      </mx:dataProvider>

       

      I want to open the sub group programatically by traversing this Grouping Collection. I am able to open the first Group. But while I am trying to open the inner Groups it is not working. if anyone can help with a working solution it will be very helpfull as I need this urgently. My code is below.

       

                      var dataCursor : IHierarchicalCollectionViewCursor;
                      var dataCursorChild : IHierarchicalCollectionViewCursor;
                         if (accountTypeADG.visible) {
                             dataCursor = accountTypeHirchColl.createCursor() as IHierarchicalCollectionViewCursor;
                         } else {
                             dataCursor = accountTypeHirchCollRealTime.createCursor() as IHierarchicalCollectionViewCursor;
                         }
                      dataCursor.seek(CursorBookmark.FIRST);
                      while(!dataCursor.afterLast) {
                          if (StringUtil.trim(dataCursor.current["GroupLabel"]) == "Assets By Account Type") {
                               for(var cnt:int = 0;cnt < dataCursor.current.children.source.length;cnt++) {
                                   if (asstClass == "Banking Accounts") {
                                       asstClass = "c";
                                   } else if (asstClass == "Investment Management Accounts") {
                                       asstClass = "a";
                                   } else if (asstClass == "Cash Management Access Account") {
                                       asstClass = "b";
                                   } else if (asstClass == "Loans") {
                                       asstClass = "d";
                                   }
                                  if (StringUtil.trim(dataCursor.current.children.source[cnt]["GroupLabel"]) == asstClass) {
                                      if (accountTypeADG.visible) {
                                          accountTypeADG.expandChildrenOf(dataCursor.current.children.source[cnt],true);
                                      } else {
                                          accountTypeADGRealtime.expandChildrenOf(accountTypeADGRealtime.dataProvider.getChildren(d ataCursor.current)[cnt],true);
                                      }
                                  }
                              } 
                          }
                          dataCursor.moveNext();
                      }
                      if (accountTypeADG.visible) {
                          accountTypeADG.dataProvider.refresh();
                      } else {
                          accountTypeADGRealtime.dataProvider.refresh();
                      }

       

      Thanks in advance.