4 Replies Latest reply on Dec 21, 2009 11:40 AM by dunn1974

    Setting a DataProvider to a custom itemRenderer in a DataGrid

    dunn1974 Level 1



      I've got a DataGrid, with one column using a custom AS itemRenderer to display a ComboBox.  Everything works, but there are various "wierd" behaviors occuring (when I remove a row, the ComboBox of the next row in line resets to it's label, but none of the others do...  When I add a row, various apparently random comboboxes change their selectedItem, etc...)


      Anyways, I had some luck isolating each of these individual bugs and squashing them, but each time I do, others seem to pop up.  I suspect the main issue is the way I'm setting the ComboBox's dataProvider.  The dataProvider is dynamic - an XML file generated from a MySQL table using PHP.  Knowing no other way to do so, I'm overriding the set data method and explicitly setting it there, like so:


      override public function set data(value:Object):void{

        super.data = value;


        dataProvider = value.uom;  // value.uom is the XML



      Is there a better way to set the data provider - an approach where I can set it once and therefor avoid the override entirely?  Again, the itemRenderer is an ActionScript class, and not implemented with XML...


      <mx:DataGridColumn itemRenderer="renderers.UOMBox" dataField="uom" headerText="UOM" />




      package renderers{

        public class UOMBox extends ComboBox{

          ... etc ...

      Thanks in advance.