6 Replies Latest reply on Jun 12, 2009 6:00 AM by SteveDepp

    New ArrayCollection, 'Tis a puzzlement.....

    Jim Daniel Level 1

      I have an ArrayCollection 'FoxsData' that was created from an AMFPHP mySQL call.  It is used in a DataGrid as the dataProvider.  So far everything is copacetic.  My problem is that I have several inline itemRender elements in DataGridColumns that don't work.  That is they don't update when the ArrayCollection is updated.  I know this is because the binding of ArrayCollection data, example source={data.Image} doesn't take place because the basic Object class is used in the ArrayColloction.

       

      What I need to know is how to get the the bloody thing to bind correctly.  I don't see how I can change the ArrayCollection constitute Object elements into some bindable form.  Do I need to create an ItemRender function in ActionScript or what?

       

      Here is the code:

       

                              <mx:DataGrid x="10" y="10" id="MyFoxes" wordWrap="true"
                                  dataProvider="{FoxsData}" 
                                  width="665" height="262" rowHeight="40"
                                  borderColor="#603913" themeColor="#603913"
                                  alternatingItemColors="[#CE7926, #E3E5DA]"
                                  alpha="1.0" editable="false" borderStyle="solid" borderThickness="3">
                                  <mx:columns>
                                      <mx:DataGridColumn headerText="" dataField="Image" width="50">
                                          <mx:itemRenderer>
                                              <mx:Component>
                                                  <mx:Image source="{data.Image}" horizontalAlign="center" verticalAlign="middle"/>
                                              </mx:Component>
                                          </mx:itemRenderer>
                                      </mx:DataGridColumn>
                                      <mx:DataGridColumn headerText="Name" dataField="Name" textAlign="center" width="250">
                                          <mx:itemRenderer>
                                              <mx:Component>
                                                  <mx:LinkButton label="{data.Name}" color="#603913" textDecoration="underline" click="parentApplication.displayFoxData(event)">
                                                  </mx:LinkButton>
                                              </mx:Component>
                                          </mx:itemRenderer>
                                      </mx:DataGridColumn>
                                      <mx:DataGridColumn headerText="Breed" dataField="Common_Name" textAlign="center" width="90" fontWeight="bold"/>
                                      <mx:DataGridColumn headerText="Stage" dataField="Stage" textAlign="center"  width="45" fontWeight="bold" labelFunction="getStageCode"/>
                                      <mx:DataGridColumn headerText="Gender" dataField="Gender" textAlign="center" width="60" fontWeight="bold" labelFunction="getGenderCode"/>
                                      <mx:DataGridColumn headerText="Visits" dataField="Visits" textAlign="center" width="45" fontWeight="bold"/>
                                      <mx:DataGridColumn headerText="Treats" dataField="Treats" textAlign="center" width="50" fontWeight="bold"/>
                                      <mx:DataGridColumn headerText="Fox Code" dataField="CodeName" textAlign="center">
                                          <mx:itemRenderer>
                                              <mx:Component>
                                                  <mx:Button label="Get Link" color="#603913" textDecoration="underline" click="parentApplication.generateFoxCode(event)">
                                                  </mx:Button>
                                              </mx:Component>
                                          </mx:itemRenderer>                                   
                                      </mx:DataGridColumn>
                                  </mx:columns>
                              </mx:DataGrid>