Yep, the problem is that grid.columns returns a COPY of the columns array. This is in the docs, but is not obvious.
Do this: var aColumns:Array = grid.columns; //then do the column creation and push stuff like you are, to the aColumns array Then, and this critical, grid.columns = aColumns; Tracy Spratt, Lariat Services, development services available _____ From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of tim_romano Sent: Thursday, October 22, 2009 9:35 AM To: flexcoders@yahoogroups.com Subject: [SPAM] [flexcoders] example of CheckBoxDataGrid in ActionScript: mine ignores col properties Although I've succeeded in creating an mxml version of Alex Harui's CheckBoxDataGrid, I'm new at Flex coding, and my ActionScript version isn't succeeding. An example would be very helpful. BTW, I can include a 'selected' column in my dataProvider, or I can leave it out. In my attempts, the grid is displaying every column in my ArrayCollection, ignoring ALL of my explicitly defined column-creation properties, which set one column to be invisible and turns off other properties, such as draggable and sortable. In mxml you can set the dataProvider and set these column properties, but in ActionScript, it appears to be the case that if you assign an ArrayCollection to the dataProvider property, the grid simply uses the collection as the columns definition. Also, Alex's drawItem method is blowing up with a TypeError, but not in the mxml version. Thanks in advance for the help. Here's what I have so far: private var grid: CheckBoxDataGrid= new CheckBoxDataGrid; grid.height=300; grid.allowMultipleSelection=true; var selcol:DataGridColumn=new DataGridColumn; selcol.itemRenderer= new ClassFactory(CheckBoxRenderer); selcol.editable=true; selcol.draggable=false; selcol.sortable=false; selcol.headerText="" selcol.visible=true; selcol.dataField="selected"; grid.columns.push(selcol); var wordcol:DataGridColumn=new DataGridColumn; wordcol.dataField="spelling"; wordcol.headerText="spelling"; grid.columns.push(wordcol); var idcol:DataGridColumn = new DataGridColumn; idcol.dataField="wrdid"; idcol.visible=false; idcol.width=0; // attempt to make invisible since visible=false fails idcol.headerText="id"; grid.columns.push(idcol); grid.dataProvider =myBindableArrayCollection; -- My class BindableArrayCollection simply wraps an ObjectProxy around each element in the array: import mx.collections.ArrayCollection; import mx.utils.ObjectProxy; public dynamic class BindableArrayCollection extends ArrayCollection { public function BindableArrayCollection(source:Array=null) { for (var s:String in source) { source[s] = new ObjectProxy(source[s]); } super(source); } }