Here is a post about datagrid item and header CheckBox renderers in flex 3 : http://shemesh.wordpress.com/2008/05/01/generic-datagrid-checkbox-header-renderer/.
It's well done, and acting directly to modify the data of each row when changing the checkboxes, avoiding to handle more events.
However my need was to make all the items checked at the begining (creationComplete). Unfortunatly when all items are selected at the begining, the header checkbox is not.
So here's my little modification of CheckBoxHeaderRenderer.mxml to fix that :
private function checkForSelectedItems():void {
var dp:ArrayCollection = _dataGrid.dataProvider as ArrayCollection;
if(dp) {
var n:Number = 0;
for(var i:int=0 ; i < dp.length ; i++){
if(dp[i][_dataField])
n++
}
if(n == dp.length){
_CBselected = true;
}else{
_CBselected = false;
}
}
}
|
Flexivement yours!
Aucun commentaire:
Enregistrer un commentaire