简体   繁体   中英

AS3 Flash checkbox in datagrid

I have successfully fill the grid from mysql database using service. I have datagrid like this

 Col_1     Col_2    Col_3    Col_4
[Chekbox]  value    value    value
[Chekbox]  value    value    value
[Chekbox]  value    value    value
[Chekbox]  value    value    value

NOTE: plid is value for checkboxes

for (varName in returnObj) {
var plid                = int   (returnObj[varName]["plid"]);
var varState            = String(returnObj[varName]["state"]);
var varCity             = String(returnObj[varName]["city"]); 

 arrDP.push({        //arrDP is array defined
  //Column          Value
  Select          : plid, 
  State           : varState,
  City            : varCity
});

var dp:DataProvider              = new DataProvider(arrDP);
var select:DataGridColumn        = dg.addColumn("Select");
var state :DataGridColumn        = dg.addColumn("State");
var city  :DataGridColumn        = dg.addColumn("City");    
dg.dataProvider                  = dp; //dg IS DATAGRID NAME AND dp IS DATAPROVIDER
}

value for chekboxes is: 1 & 0. where 1 mean TRUE(selected) and 0 mean FALSE(not selected). my question is how to show checkboxes to be SELECTED for value 1?? as checkbox need an event to be occur for state change. I am using the following cellrender class.

http://www.actionscript.org/forums/showthread.php3?t=234416

Thanks in advance.

  1. Create the CheckBox instance.
  2. Check if the plid is 1 or 0 and toggle the checkbox accordingly.

Like so:

//The checkbox instance variable name in this example is cb
cb.selected = plid == 1 ? true : false;

The selected getter/setter indicates if the CheckBox is to be displayed as checked or not.

Read more about that here: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/controls/LabelButton.html#selected

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM