1 Reply Latest reply: Oct 19, 2011 10:50 AM by Don Kerr RSS

    Spark DataGrid -Dynamically change cell background color

    Don Kerr Community Member

      I have one column that is a dropdownlist.  When any change is made, I set data.action to 'Update'


      protected function cb_changeHandler(event:IndexChangeEvent):void


                                                                                                                                                            data.officeID = cb.selectedItem.ID;

                                                                                                                                                            data.office = cb.selectedItem.name;

                                                                                                                                                                      data.action = 'Update';



      I want the other action column background to change based on the new value of data.action


      <s:GridColumn   width="70" editable="false" headerText="Action" dataField="action">



      <s:DefaultGridItemRenderer background="true"  backgroundColor="{data.action == 'Keep' ? 0x00ff00: data.action == 'Update' ? 0xFFCC00: data.action == 'New' ? 0xffff00: data.action == 'Delete' ? 0xff0000:0x000000}>






      Problem is that the data updates, but the color does not.  After scrolling the DataGrid the color does update.  However, I need it to update the color immediately.


      Another problem is calling refresh() on the dataProvider does update the colors, but sometimes it causes the wrong row or additional rows to change colors.  Very strange.  There seems to be nothing consistent.  It appears to random change any rows color.


      How do the get the grid to redraw the backgroundColor immediately when the dropdown is changed?