I used to bind the selectedIndex of the ComboBoxes in my application to a function that determined the correct index to select given an array of options and the data that I want to select. I found this method to be slow and error prone as the selectedIndex function would be called every time the array OR the data changed. Every time the data changed, flex would run the selectedIndex function about 15 times before it would realize that it was in an infinite loop. This "infinite loop" resulted from the binding from the selectedItem's data to a data field in a model. Every time a change occured the data would update in the model which would cause the selectedIndex function to run which would change the selected data, bind to the model, ... and so on.
This method was also error-prone because if the data in the model was updated in the wrong order, the wrong item would be selected. If the selectedIndex function ran too early, the wrong value would be selected and bound into the model and the original value in the model would be lost. So... since this method was slow and error prone I decided to add a new field in the model that would store an initial selectedIndex for the ComboBox. This works very well - all I have to do is bind to the selectedIndex field in the model and update the selectedIndex field in the model using the selectedIndex function. Now binding only occurs when the selectedIndex field in the model changes... instead of 15 times every time data in the model is updated. After I made the change throughout the application I starting having problems with the parts of the application that were generated using repeaters. It took me awhile but I finally figured out what was going on. If the repeated object contained a drop down menu and two instances of the drop down menu both had the same option selected the underlying object selected in the ComboBox's datasource would get its data field set to undefined whenever the main model (the model containing both the data from the selected item and the selectedIndex) changed. For example, consider a model called Client that contains a field called StateID and another called StateIndex. If I contruct an array of Client models and output that array using a Repeater I could change the state for each client. The object that is repeated for each Client contains a drop down menu for the state. The datasource for each ComboBox is ModelLocator.States, the selectedIndex is bound to Client.StateIndex and a Binding tag is used to bind the ComboBox.selectedItem.ID to Client.StateID. The State objects in the ModelLocator.States array have two properties - ID and Name. Now if I select the same state for more than one Client and then create a new Client object or load a different client object the state that was selected more than once gets its ID field set to undefined which, in turn, binds into the new Client.StateID. So, the new or different Client object now has an undefined StateID. Also, EVERYTHING that uses ModelLocator.States shows that the ID field for that state is now undefined. Even components outside of the repeater show this change to the state, so the change is in the array itself. Finally, I got the application working again by using a TileList instead of a Repeater. However, now there's a different problem with the drop down menus - when they are enabled and the mouse is not over them the width of the box sometimes changes to about 50 px, causing the text to stick out of the box. The only part of the ComboBox that is visible is the down arrow but all of the text is visible for the selected option. The drop down menus have a set static width and the repeated object is a Canvas control. Also, all of the controls within the repeated object have fuzzy borders now that they're in the TileList. So... some questions. How could the ID property of a state change if nothing there is no code that changes it? The Name field doesn't change, just the ID field. If I rename ID to value but use it in the same manner, the value field gets set to undefined. But there's no code in the entire application that changes IDs for states. Why does a TileList implementation work, but not a repeater implementation? Why do some of the ComboBoxes in the TileList implementation sometimes display incorrectly? The problem will occur only if the ComboBox is not disabled and the mouse is not hovering over the ComboBox. But even then, it only happens in the first object. Finally, why do the repeated controls now have fuzzy borders? The repeated object has a checkbox, some textinput controls and a ComboBox. All of these now have fuzzy borders that are causing my eyes to hurt. Thanks for your help.. I know this is really long but I've been tearing my hair out for about six hours on this. Any ideas would be greatly appreciated! Moishe Groger ------------------------ Yahoo! Groups Sponsor --------------------~--> You can search right from your browser? It's easy and it's free. See how. http://us.click.yahoo.com/_7bhrC/NGxNAA/yQLSAA/nhFolB/TM --------------------------------------------------------------------~-> -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/