1 Reply Latest reply on Oct 5, 2007 5:15 PM by Gregory Lafrance

    Setting style  for DatagridColumn?

    mouse jockey Level 1
      My dataGrid has a style set for it in the CSS stylesheet. How can I change the style for one of the columns please?
        • 1. Re: Setting style  for DatagridColumn?
          Gregory Lafrance Level 6
          If your DataGridColumn has an id set for it, you can use the setStyle() method to set individual styles.
          <?xml version="1.0"?>
          <!-- dragdrop\SimpleDGToDG.mxml -->
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
          creationComplete="initApp();">
          <mx:Script>
          <![CDATA[
          private function initApp():void {
          greg.setStyle("backgroundColor","#ff00ff");
          srcgrid.dataProvider = [
          {Artist:'Carole King', Album:'Tapestry', Price:11.99},
          {Artist:'Paul Simon', Album:'Graceland', Price:10.99},
          {Artist:'Original Cast', Album:'Camelot', Price:12.99},
          {Artist:'The Beatles', Album:'The White Album', Price:11.99}
          ];

          }
          ]]>
          </mx:Script>

          <mx:DataGrid id="srcgrid">
          <mx:columns>
          <mx:DataGridColumn id="greg" dataField="Artist"/>
          <mx:DataGridColumn dataField="Album"/>
          <mx:DataGridColumn dataField="Price"/>
          </mx:columns>
          </mx:DataGrid>
          </mx:Application>