datagrid中的as3复选框

时间:2011-07-06 15:38:21

标签: flash actionscript-3

我是Flash和AS3的新手。 我有像这样的DataGrid

  col1        col2     col3    col4
[checkbox]   value    value    value
[checkbox]   value    value    value
[checkbox]   value    value    value
[checkbox]   value    value    value

Datagrid在数据网格中使用services.100记录每页动态地从mysql填充。 如果我选择一些复选框并转到下一页并选择其他一些而不是回到第1页。应该选中我之前选择的复选框。

我在php会话中有第1页复选框值,我可以在flash中访问这些值,但我不知道如何设置checboxes checked = true; 因为复选框上没有发生CHANGE事件。

我正在使用吼叫课。 http://www.actionscript.org/forums/showthread.php3?t=234416

Plz帮助我任何人

@Josh Mohan

:(没有运气。你可以查看以下代码。并纠正我如何调用

CheckCellClass.onCheckChange(new Event(Event.CHANGE));

function showSearchCriteria(returnObj:Object){// RETURN是数据库中的值     var varName:String;     for(returnObj中的varName){

    /* NOTE : In this loop i want to set checkbox boxes to be checked. i mean selected = true;*/

    var plid                        = int   (returnObj[varName]   ["plid"]); //THIS IS GOING TO ASSIGN TO CHECKBOX
    var varState            = String(returnObj[varName]["state"]);
    var varCity             = String(returnObj[varName]["city"]);
    var varacgmeid          = String(returnObj[varName]["acgmeid"]);
    var varProgramname      = String(returnObj[varName]["programname"]);
    var varUrl              = String(returnObj[varName]["url"]);
    var varNoofseats        = int   (returnObj[varName]["noofseats"]);
    var varDeadline         = String(returnObj[varName]["deadline"]);
    var varYearofpassing    = int   (returnObj[varName]["passYear"]);
    var varScore            = int   (returnObj[varName]["stepone2digit"]);
    var varSteponeattempt   = int   (returnObj[varName]["steponeattempt"]);
    var varObservership     = int   (returnObj[varName]["observership"]);
    var varExternship       = int   (returnObj[varName]["externship"]);
    var varj1h1bf1          = String(returnObj[varName]["visa"]);
    var varProgramtype      = String(returnObj[varName]["programtype"]);
    var varComment          = String(returnObj[varName]["comment"]);
    var varContact          = String(returnObj[varName]["contact"]);

    //plid.onCheckChange (new Event(Event.CHANGE));
    arrDP.push({
      //Column            Value
       Select           : plid, 
       State            : varState,
       City             : varCity,
       ACGMEID          : varacgmeid,
       ProgramName      : varProgramname,
       NoofnSeats       : varNoofseats,
       Deadline         : varDeadline,
       YearFromPassing  : varYearofpassing,
       Scores           : varScore,
       Attempts         : varSteponeattempt,
       UsExperience     : varObservership,
       NoofMonths       : varExternship,
       VisaSponsored    : varj1h1bf1,
       Type             : varProgramtype,
       More             : "Show"
    }); //push end here..
} //for end here..

var dp:DataProvider              = new DataProvider(arrDP);

var select:DataGridColumn        = dg.addColumn("Select");
var state :DataGridColumn        = dg.addColumn("State");
var city  :DataGridColumn        = dg.addColumn("City");
var acgmeid :DataGridColumn      = dg.addColumn("ACGMEID");
var programname :DataGridColumn  = dg.addColumn("ProgramName");
var noofseats:DataGridColumn     = dg.addColumn("NoofnSeats");
var deadline:DataGridColumn      = dg.addColumn("Deadline");
var yearofpassing:DataGridColumn = dg.addColumn("YearFromPassing");
var scores:DataGridColumn        = dg.addColumn("Scores");
var attempts:DataGridColumn      = dg.addColumn("Attempts");
var usexperience:DataGridColumn  = dg.addColumn("UsExperience");
var noofmonths:DataGridColumn    = dg.addColumn("NoofMonths");
var visasponsored:DataGridColumn = dg.addColumn("VisaSponsored");
var type:DataGridColumn          = dg.addColumn("Type");
var more:DataGridColumn          = dg.addColumn("More");

select.cellRenderer              = ButtonRenderer; //CELL RENDER FOR CHECKBOX       

dg.dataProvider         = dp;

}

1 个答案:

答案 0 :(得分:0)

您正在使用的类已覆盖selected属性的Checkbox类'setter,从而无法使用selected属性检查或取消选中该框。

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/controls/LabelButton.html#selected

CODE:

override public function set selected(value:Boolean):void { 
}

<强>解: 在不更改类的情况下,允许setter更改超类的selected属性,有两个选项:

A)手动调用事件处理程序onCheckChange并将其传递给null事件或虚拟事件:

CheckCellClass.onCheckChange (new Event(Event.CHANGE));

B)将Event.CHANGE事件发送到事件流中以触发事件处理程序:

CheckCellClass.dispatchEvent (new Event (Event.CHANGE));