Oups, effectivement, la propriété "editable" (et non pas "headerText"...) de la première colonne est bien entendu à false... Il faut donc lire :
<mx:DataGridColumn headerText="" editable="false" width="255" fontWeight="bold" />
Quant au code du renderer, le voici :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| <?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" horizontalAlign="center">
<mx:Script>
<![CDATA[
import mx.utils.ObjectUtil;
public var selectedNiveau:int=1;
[Bindable]
private var niveaux:Array = [
{label:"Valeur 1", value:1},
{label:"Valeur 2", value:2},
{label:"Valeur 3", value:3}
];
override public function set data(value:Object):void {
super.data = value;
if (value != null) {
var currentValue:int = value.NIVEAU;
for (var i:int = 0; i < this.niveaux.length; i++) {
if (this.niveaux[i].value == currentValue) {
this.cb.selectedIndex = i;
break;
}
}
}
}
public function onChange():void {
var index:int = this.cb.selectedIndex;
this.selectedNiveau = this.niveaux[index].value;
}
]]>
</mx:Script>
<mx:ComboBox id="cb" dataProvider="{niveaux}" width="120" change="onChange()" prompt="Sélectionner..." />
</mx:VBox> |
Partager