开发者

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
}

valu开发者_如何学运维e 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜