Consider a data grid with checkboxes in the 1st column. The checkboxes are used to select which preferences the user desires. The dataProvider of the DataGrid is X, which is read from a database or XML file. X is a collection of all possible preferences.
Ignore for the moment that I am not using getters/setters.
ActionScript Code:
public var X:ArrayCollection; // collection of all possible preferences
public var Y:Array; // preferences chosen by user
Let's say the users preferences are accessible via Y, an Array, which contains only those preferences the user has previously chosen. How would you initialize the datagrid such that the checkbox for each preference that the user has chosen is checked?
The solution I have always used is to iterate through both X & Y, and if X & Y "match", add a new property called "Selected" to the object in X which is set to true. Then in the DataGrid CheckBox itemRenderer, set selected="{data.Selected}".
Is there a better way to go about this other than creating "temporary" data sets by merging separate data sets?