Can you post a small runnable example? Tracy
________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Geoffrey Sent: Wednesday, April 04, 2007 3:25 PM To: [email protected] Subject: [flexcoders] Re: Nested Repeater Issues Bump --- In [email protected] <mailto:flexcoders%40yahoogroups.com> , "Geoffrey" <[EMAIL PROTECTED]> wrote: > > I have a Repeater of CheckBoxes, which may or may not have a sublayer > of CheckBoxes. It should look something like: > [] archive 1 > [] archive 2 > [] dataSource 1 > [] dataSource 2 > [] dataSource 3 > [] archive 3 > > By default all CheckBoxes are unselected, and any > sublayer CheckBoxes are not enabled. If you select a CheckBox(archive > 2) that has sublayer CheckBoxes (dataSource 1- 3), they are enabled. > If you unselect a CheckBox that has sublayer CheckBoxes, they are > disabled and unselected. > > I'm using the Cairngorm framework, so the call results from the > database are returned to my model. This model is used as the > dataProvider for the Repeater. > > The issue is that I can not update my model and have the sublayer > Repeater update properly. For example, if there are three sublayer > CheckBoxes (like above), selecting the parent CheckBox (archive 2) > will enable only the first 2 sublayer CheckBoxes (dataSource 1 & 2). > Then deselecting the parent CheckBox will disable the first 2 sublayer > CheckBoxes, but enable the third (dataSource 3). From this point on > the enabled property for dataSource 1&2 will be in a opposite state > from dataSource 3. > > Below are code snippets: > ---------------------------------------------------------- > Library.mxml: > <mx:Repeater id="archiveRepeater" > dataProvider="{__model.archiveElements}"> > > <mx:CheckBox id="archive" > label="{archiveRepeater.currentItem.archiveName}" > click="__model.archiveChanged(event)"/> > > <mx:Repeater id="dataSourceRepeater" > dataProvider= > "{archiveRepeater.currentItem.archiveDataRepositories}"> > > <mx:CheckBox id="dataSource" > label="{dataSourceRepeater.currentItem.repositoryName}" > enabled="{dataSourceRepeater.currentItem.enabled}" > selected="{dataSourceRepeater.currentItem.selected}" > click="__model.dataSourceChanged(event)"> > > </mx:CheckBox> > </mx:Repeater> > </mx:Repeater> > ---------------------------------------------------------- > > ---------------------------------------------------------- > LibraryModel.as: > public function archiveChanged( event:MouseEvent ):void > { > var selectionChoice:Boolean = event.target.selected; > var selectionName:String = event.target.label; > var al:ArchiveLocation = > ArchiveLocation(event.target.getRepeaterItem()); > al.selected = selectionChoice; > > // Go through any data repositories > // and toggle their enabled property > if (al.archiveDataRepositories != null) > { > var adr:Array = al.archiveDataRepositories; > if (selectionChoice == false) > { > // Deselect and disable all CheckBoxes > for (var i:uint = 0; i < adr.length; i++) > { > // Update the model > adr[i].selected = false; > adr[i].enabled = false; > } > else > { > // Enable all CheckBoxes > for (i = 0; i < adr.length; i++) > { > adr[i].enabled = true; > } > } > } > } > } > ---------------------------------------------------------- > > As you can tell, there are ValueObjects that store the enabled and > selected attributes for the dataSource CheckBoxes. > > What's even weirder, is that the ValueObjects that make up the > dataProvider for the Repeater are updated correctly (their selected > and enabled properties), but the last CheckBox of any sublayer remains > in a state that is opposite of the other grouped sublayer CheckBoxes. > > I've gotten around this by directly updating the display by using: > event.target.document.dataSource[i][j].enabled = false; > But I don't want to rely on this as it will cause issues later on. > > I feel that I should be able to update the dataProvider for the > various Repeaters and this should update the display properly. Any > suggestions would be greatly appreciated. > > ~Geoff~ >

