3 Replies Latest reply on Nov 22, 2009 9:52 PM by manishmulani

    AdvancedDataGridColumn DataField problem


      I've a XML which is the dataProvider to AdvancedDataGrid.


      XML looks like this




         <count type="success">30</count>

         <count type="failed">40</count>

         <count type="skipped">20</count>







      I've three columns in AdvancedDataGrid , countSuccess , countFailed, countSkipped


      I want to show 30 , 40 , 20 in these columns respectively..


      I tried setting the dataField = "positions.count.(@type="success")"   . similarly for each of three columns

      This doesn't work

        • 1. Re: AdvancedDataGridColumn DataField problem
          paul.williams Level 4

          I doubt the DataGridColumn will handle this kind of conditional dataField expression. Support has been added in 3.4 for nested properties, but you've gone beyond that. I would suggest using a labelFunction instead:


          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
                      import mx.controls.dataGridClasses.DataGridColumn;
                      private static const COUNT_SUCCESS : String = "countSuccess";
                      private static const COUNT_FAILED : String = "countFailed";
                      private static const COUNT_SKIPPED : String = "countSkipped";
                      private var myXML : XML = <data>
                              <count type="success">30</count>
                              <count type="failed">40</count>
                              <count type="skipped">20</count>
                              <count type="success">12</count>
                              <count type="failed">15</count>
                              <count type="skipped">93</count>
                              <count type="success">15</count>
                              <count type="failed">45</count>
                              <count type="skipped">6</count>
                      private function labelFunction( value : Object, column : DataGridColumn ) : String
                          var result : String;
                          var position : XML = XML( value );
                          switch( column.headerText )
                              case COUNT_SUCCESS : result = position.count.(@type=="success"); break;
                              case COUNT_FAILED : result = position.count.(@type=="failed"); break;
                              case COUNT_SKIPPED : result = position.count.(@type=="skipped"); break;
                              default : throw new Error( "Unknown column: " + column.headerText ); break;
                          return result;
                  dataProvider="{ myXML.positions }"
                      <mx:DataGridColumn headerText="{ COUNT_SUCCESS }"/>
                      <mx:DataGridColumn headerText="{ COUNT_FAILED }"/>
                      <mx:DataGridColumn headerText="{ COUNT_SKIPPED }"/>

          • 2. Re: AdvancedDataGridColumn DataField problem
            ShankarFlex3 Level 2



            Are you able to modify your xml if so try to do it this way









            Now you can access the values by "positions.success", "positions.failed" and "positions.skipped".


            Hope this helps.

            • 3. Re: AdvancedDataGridColumn DataField problem
              manishmulani Level 1

              Thanks paul.williams


              This is what I was looking for.