hi,
?how to change the column color in datagrid at runtime after bind the data into the grid.kindly tell me which event i would like to handle .
thanks
Woodson.
column color change at runtimeHi
You can listen for changes to the datagrids dataProvider, and reacting to that, set the backGround color using the style property for the column.
%26lt;?xml version=''1.0'' encoding=''utf-8''?%26gt;
%26lt;mx:Application xmlns:mx=''http://www.adobe.com/2006/mxml'' layout=''absolute'' creationComplete=''handleCreation()'' %26gt;
?%26lt;mx:Script%26gt;
?%26lt;![CDATA[
?import mx.events.CollectionEvent;
?import mx.collections.ArrayCollection;
?
?private var myArray:Array = new Array({name :'Chris'});
?
?[Bindable]
?private var ac:ArrayCollection = new ArrayCollection([
?{name : 'Andrew'}]);
?
?private function handleCreation():void {
?ac.addEventListener(CollectionEvent.COLLECTION_CHANGE, handleDataChange);
?}
?
?private function handleDataChange(event:CollectionEvent):void {
?col1.setStyle('backgroundColor',0xe5e5e5);
?}
?
?private function changeData():void {
?ac.source = myArray;
?
?}
?]]%26gt;
?%26lt;/mx:Script%26gt;
?
?%26lt;mx:DataGrid id=''dg'' x=''101'' y=''112'' dataProvider=''{ac}''%26gt;
?%26lt;mx:columns%26gt;
?%26lt;mx:DataGridColumn id=''col1'' headerText=''name'' dataField=''name'' /%26gt;
?%26lt;mx:DataGridColumn headerText=''Column 2'' dataField=''col2''/%26gt;
?%26lt;mx:DataGridColumn headerText=''Column 3'' dataField=''col3''/%26gt;
?%26lt;/mx:columns%26gt;
?%26lt;/mx:DataGrid%26gt;
?%26lt;mx:Button x=''101'' y=''288'' label=''Change Data'' click=''changeData()''/%26gt;
?
%26lt;/mx:Application%26gt;
Hope that helps.
Andrew
No comments:
Post a Comment