1 Reply Latest reply on Dec 20, 2010 5:59 AM by g.Cardinal

    Learning Flex: AdvancedDataGrid, XML and Grouping

    g.Cardinal

      Hi everyone,

       

      At work they recently decided they wanted to start using Flex for some of their interfaces, which is nice since (having played around for a week now) it seems like it can allow us to build efficient interfaces quickly.

       

      One problem I am having is I'm trying to build and AdvancedDataGrid, but, I'm having problems grouping some of the data together. What I'm basicaly displaying is a list of persons, with various info, and some of those person can have been referenced by others, when they have been, people who referenced them should be grouped under them. Like that in fact:

       

      DataGridExample.jpg

       

      This is the XML that should feed the DataGrid. Basicaly, <KOL> is a row in the DataGrid, and when there is a <Linked> tag, the <KOL> in the<Linked> tag make it so there is an arrow next to the person's name.

       

      <?xml version="1.0" encoding="utf-8" ?>
      <data>
          <KOL>
              <type>rouge</type>
              <name>Random Name</name>
              <phone>514-555-1234</phone>
              <otherInfo>Something something</otherInfo>
              <Linked>
                  <KOL>
                      <name>Random Name</name>
                      <phone>514-555-1234</phone>
                      <otherInfo>Something something</otherInfo>
                  </KOL>
                  <KOL>
                      <name>Random Name</name>
                      <phone>514-555-1234</phone>
                      <otherInfo>Something something</otherInfo>
                  </KOL>
                  <KOL>
                      <name>Random Name</name>
                      <phone>514-555-1234</phone>
                      <otherInfo>Something something</otherInfo>
                  </KOL>
                  <KOL>
                      <name>Random Name</name>
                      <phone>514-555-1234</phone>
                      <otherInfo>Something something</otherInfo>
                  </KOL>
              </Linked>
          </KOL>
          <KOL>
              <type>jaune</type>
              <name>Random Name</name>
              <phone>514-555-1234</phone>
              <otherInfo>Something something</otherInfo>
              <Linked>
                  <KOL>
                      <name>Random Name</name>
                      <phone>514-555-1234</phone>
                      <otherInfo>Something something</otherInfo>
                  </KOL>
                  <KOL>
                      <name>Random Name</name>
                      <phone>514-555-1234</phone>
                      <otherInfo>Something something</otherInfo>
                  </KOL>
                  <KOL>
                      <name>Random Name</name>
                      <phone>514-555-1234</phone>
                      <otherInfo>Something something</otherInfo>
                  </KOL>
                  <KOL>
                      <name>Random Name</name>
                      <phone>514-555-1234</phone>
                      <otherInfo>Something something</otherInfo>
                  </KOL>
              </Linked>
          </KOL>
          <KOL>
              <type>bleu</type>
              <name>Random Name</name>
              <phone>514-555-1234</phone>
              <otherInfo>Something something</otherInfo>
          </KOL>
          <KOL>
              <type>bleu</type>
              <name>Random Name</name>
              <phone>514-555-1234</phone>
              <otherInfo>Something something</otherInfo>
          </KOL>
      </data>

       

      Also, I can display the info of individual KOLs, but I can't seem to create the groups when there is a <Linked> tag... Is what I'm trying even possible? If yes, is my logic wrong?

       

      Forgot to post my code, here it is:
      columns is an Array where I store the current Columns names. Not very useful here. adg1 is my AdvancedDataGrid.


      private function createAdvancedDataGrid():void
      {
          var colArray:Array /* of AdvancedDataGridColumn */ = [];
          for(var item:* in flashVars)
          {
              columns.push(String(flashVars[item]));
              var columnName:String = String(flashVars[item]).split(" | ")[0];
              var col:AdvancedDataGridColumn = new AdvancedDataGridColumn(columnName);
              col.dataField = String(item);
              colArray.push(col);
          }
          adg1.groupedColumns = colArray;
          adg1.dataProvider = dataXML;
          //adg1.columns = colArray;
      }