Bonjour,

j'utilise un itemEditor tout simple dans un dataGrid. Cela marche bien sauf que lorsque je quitte l'itemEditor pour réafficher l'itemRenderer par défaut, j'ai quelque fois (pas toujours) un alignement vertical dans la cellule erroné.

Voici le code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
 
...
colonne = new DataGridColumn();
colonne.setStyle("textAlign", TextAlign.CENTER);
colonne.setStyle("verticalAlign", VerticalAlign.MIDDLE);
colonne.dataField = "accu_totale";	
colonne.headerText = "accu. intraday";
colonne.itemEditor = new ClassFactory(AccuEditor);
colonne.editorDataField = "retour";
colonne.labelFunction = number_format_items;
colonne.setStyle("color", 0x0000FF);	
colonnes.push(colonne);
...
Mon itemEditor:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
 
package itemEditor
{	
	import mx.collections.ArrayCollection;
	import mx.containers.VBox;
	import mx.controls.Alert;
	import mx.events.FlexEvent;
 
	import spark.components.TextInput;
	import spark.events.TextOperationEvent;
	import spark.layouts.HorizontalAlign;
	import spark.layouts.VerticalAlign;
 
	public class AccuEditor extends VBox 
	{		
		[Bindable] public var retour:String;
		private var _data:Object;
		private var textInput:TextInput;	
 
		[Bindable]
		override public function set data(value:Object):void{
			_data = value;
			draw();			
		}
 
		override public function get data():Object{
			return _data;
		}
 
		private function draw():void
		{
			removeAllElements();
 
			setStyle("horizontalAlign", HorizontalAlign.CENTER);
			setStyle("verticalAlign", VerticalAlign.MIDDLE);
 
			textInput = new TextInput();
			textInput.percentWidth = 90;
 
			textInput.text = data.accu_totale;
			textInput.restrict = "0-9";
			textInput.addEventListener(FlexEvent.UPDATE_COMPLETE, changeText);
			addElement(textInput);			
 
			textInput.setFocus();
		}
 
		private function changeText(event:FlexEvent):void
		{
			data.accu_totale = TextInput(event.currentTarget).text;
			retour = data.accu_totale;						
		}			
 
	}
}
Pour rappel, ma donnée une fois modifiée apparait parfois avec un alignement vertical un peu décallé vers le bas. Quelqu'un verrait il pourquoi ?

Merci