RE: [flexcoders] 2 Datagrid issue
Probably, but we'll need to see a bit of the relevant code. Start with the DataGrid declaration mxml and the change handler function. Tracy From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Simon Bailey Sent: Monday, December 29, 2008 1:37 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] 2 Datagrid issue Hi, I have 2 DataGrids working with a custom renderer and all that jazz but 2 seperate ArrayCollections as data provider. On select of an item in one grid I set the data['selected'] property accordingly and call an itemUpdated in the ArrayCollection. Can anyone think why a selection in one grid is also selecting an item in the second grid?
Re: [flexcoders] 2 Datagrid issue
Hi Tracy, // MAIN MXML ac = new ArrayCollection(dp); //dp = array of objects bc = new ArrayCollection(dp); private function onChange( e:ListEvent ):void { // Multiple checkboxes able to be selected so // deselect all then reselect single checkbox. for ( var i:int = 0; i ac.length; i ++ ) { ac.getItemAt(i).selected = false; bc.getItemAt(i).selected = false; } if( e.itemRenderer.data.column == e.columnIndex e.itemRenderer.data.row == e.rowIndex ) e.itemRenderer.data.selected = true; ac.itemUpdated( e.itemRenderer.data ); bc.itemUpdated( e.itemRenderer.data ); } // CUSTOM RENDERER override protected function clickHandler(event:MouseEvent):void { super.clickHandler(event); this.visible = false; data.selected= selected; data.row = listData.rowIndex; data.column = listData.columnIndex; } mx:VBox mx:Label text=Corrected Grid fontSize=14 fontWeight=bold/ local:CustomGrid id=dg2 paddingTop=0 paddingBottom=0 verticalAlign=middle rowHeight=20 change=onChange( event ) allowMultipleSelection=false/ /mx:VBox mx:VBox mx:Label text=Corrected Grid fontSize=14 fontWeight=bold/ local:CustomGrid id=dg3 paddingTop=0 paddingBottom=0 verticalAlign=middle rowHeight=20 change=onChange( event ) allowMultipleSelection=false/ /mx:VBox On 29 Dec 2008, at 19:03, Tracy Spratt wrote: Probably, but we’ll need to see a bit of the relevant code. Start with the DataGrid declaration mxml and the change handler function. Tracy From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Simon Bailey Sent: Monday, December 29, 2008 1:37 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] 2 Datagrid issue Hi, I have 2 DataGrids working with a custom renderer and all that jazz but 2 seperate ArrayCollections as data provider. On select of an item in one grid I set the data['selected'] property accordingly and call an itemUpdated in the ArrayCollection. Can anyone think why a selection in one grid is also selecting an item in the second grid?
RE: [flexcoders] 2 Datagrid issue
As Tim guessed in his post, your two Acs share the same source, so are essentially one dataProvider. Use concat() to make a copy of dp before you create bc. Tracy From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Simon Bailey Sent: Monday, December 29, 2008 2:19 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] 2 Datagrid issue Hi Tracy, // MAIN MXML ac = new ArrayCollection(dp); //dp = array of objects bc = new ArrayCollection(dp); private function onChange( e:ListEvent ):void { // Multiple checkboxes able to be selected so // deselect all then reselect single checkbox. for ( var i:int = 0; i ac.length; i ++ ) { ac.getItemAt(i).selected = false; bc.getItemAt(i).selected = false; } if( e.itemRenderer.data.column == e.columnIndex e.itemRenderer.data.row == e.rowIndex ) e.itemRenderer.data.selected = true; ac.itemUpdated( e.itemRenderer.data ); bc.itemUpdated( e.itemRenderer.data ); } // CUSTOM RENDERER override protected function clickHandler(event:MouseEvent):void { super.clickHandler(event); this.visible = false; data.selected= selected; data.row = listData.rowIndex; data.column = listData.columnIndex; } mx:VBox mx:Label text=Corrected Grid fontSize=14 fontWeight=bold/ local:CustomGrid id=dg2 paddingTop=0 paddingBottom=0 verticalAlign=middle rowHeight=20 change=onChange( event ) allowMultipleSelection=false/ /mx:VBox mx:VBox mx:Label text=Corrected Grid fontSize=14 fontWeight=bold/ local:CustomGrid id=dg3 paddingTop=0 paddingBottom=0 verticalAlign=middle rowHeight=20 change=onChange( event ) allowMultipleSelection=false/ /mx:VBox On 29 Dec 2008, at 19:03, Tracy Spratt wrote: Probably, but we'll need to see a bit of the relevant code. Start with the DataGrid declaration mxml and the change handler function. Tracy From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Simon Bailey Sent: Monday, December 29, 2008 1:37 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] 2 Datagrid issue Hi, I have 2 DataGrids working with a custom renderer and all that jazz but 2 seperate ArrayCollections as data provider. On select of an item in one grid I set the data['selected'] property accordingly and call an itemUpdated in the ArrayCollection. Can anyone think why a selection in one grid is also selecting an item in the second grid?