title: How set background of row dynamic using flex?
body: <p>Look my source:</p>
  
  <ul>
  <li>Template:</li>
  </ul>
  
  <p>[code]
  
  </p>
  
  <pre><code>&lt;mx:Script source="ListStatus.as" /&gt;
  
  &lt;!-- Template --&gt;
  &lt;mx:DataGrid id="grid" width="100%" height="100%" doubleClick="editRecord();"&gt;
      &lt;mx:columns  &gt;
          &lt;mx:DataGridColumn width="30" resizable="false" draggable="false"&gt;
              &lt;mx:itemRenderer&gt;
                  &lt;mx:Component&gt;
                      &lt;mx:LinkButton icon="@Embed('assets/img/delete.png')" click="outerDocument.deleteRecord(event);" /&gt;
                  &lt;/mx:Component&gt;
              &lt;/mx:itemRenderer&gt;
          &lt;/mx:DataGridColumn&gt;
          &lt;mx:DataGridColumn headerText="Nome" dataField="name" /&gt;
          &lt;mx:DataGridColumn headerText="Nome de exibição" dataField="displayName" /&gt;
          &lt;mx:DataGridColumn headerText="Cor" dataField="color" /&gt;            
      &lt;/mx:columns&gt;
  &lt;/mx:DataGrid&gt;
  </code></pre>
  
  <p>
  [/code]</p>
  
  <ul>
  <li>ActionScript:</li>
  </ul>
  
  <p>[code]
  import fuel.Ajax;
  import fuel.IModule;
  import fuel.window.Window;</p>
  
  <p>import mx.controls.Alert;
  import mx.events.ModuleEvent;
  import mx.modules.ModuleLoader;</p>
  
  <p>public var win:Window;</p>
  
  <p>/**
   * Constructor
   * 
   * Get data from turbo gears controller
   */
  public function init():void
  {<br>
      showLoading();
      Ajax.requestJSON('/access/status/getList', {}, function (obj:Object):void {
          hideLoading();
          grid.dataProvider = obj.results;
      }); 
  }</p>
  
  <p>/**
   * Call form to edit record
   */
  public function editRecord():void
  {</p>
  
  <pre><code>try {
      grid.selectedItem.id;                   
  } catch(e:Error) {
      Alert.show("Você deve selecionar um registro válido", "Atenção");
      return;
  }
  
  var module:ModuleLoader = new ModuleLoader();
  module.url = "access/CreateStatus.swf";
  module.applicationDomain = ApplicationDomain.currentDomain;
  module.addEventListener( ModuleEvent.READY, onModuleReady );
  
  var title_bar:String = "Edição de Status (" + grid.selectedItem.id + ")";
  
  if( this.window ){
      win = this.window.openChild(title_bar, module, 410, 250);
  } else {
      win = (parentApplication as Admin).winManager.openWindow(title_bar, module, 410, 250);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>/**
   * Call controller to delete record
   */
  private function actionDeleteRecord( resp:Object ):void
  {
      if( resp.detail == Alert.YES ){
          grid.enabled = false;</p>
  
  <pre><code>    Ajax.requestJSON( "/access/status/delete", { 'id' : grid.selectedItem.id }, function( obj:Object ):void {
          if (obj.error == false) {
              Alert.show("Registro deletado com sucesso", "Confirmação");
          } else {
              Alert.show(obj.msg, "Erro");
          }
  
          init();             
      });
  
      grid.enabled = true;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>/**
   * Call request to delete record
   */
  public function deleteRecord( event : Event ):void
  {
      Alert.show("Esta operação NÃO poderá ser desfeita.\nDeseja mesmo remover o status \""+grid.selectedItem.displayName+"\"?", "Confirmação", Alert.YES | Alert.NO, this, actionDeleteRecord );
  }</p>
  
  <p>public function onModuleReady( event:ModuleEvent ):void
  {<br>
      var loader:ModuleLoader = event.target as ModuleLoader;</p>
  
  <pre><code>var m:* = loader.child as IModule;
  if( m ) m.addEventListener( Event.RENDER, function runModule(e:Event):void{
      m.setId(grid.selectedItem.id);
      m.window = win;                 
      m.removeEventListener( Event.RENDER, runModule );
  });
  </code></pre>
  
  <p>};
  [/code]</p>
  
  <p>I need set background of row using the value of color how exists in dataProvider.</p>
  
  <p>Sorry for my ignorance, this is my first project using flex.</p>
  
  <p>Thank's!</p>