Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 01-27-2010, 03:18 PM   #1
SeaOfHoles
Member
 
Join Date: Sep 2007
Posts: 58
Default Initialize DataGrid Checkboxes

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?

Last edited by SeaOfHoles; 01-28-2010 at 02:32 PM.
SeaOfHoles is offline   Reply With Quote
Old 01-28-2010, 01:01 AM   #2
drkstr
Flexpert
 
drkstr's Avatar
 
Join Date: Sep 2006
Location: Seattle, WA: USA
Posts: 1,587
Default

Sounds like the only way to me.
drkstr is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:30 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.