AdvancedDataGrid itemRenderer Factory Class
Bonjour,
J`utilise une classe pour mettre en forme le contenu de chacune des cellules de ma grille. Tout fonctionne très bien et le déplacement dans la grille ce fait de façon efficace. Vous pouvez consultez le code de la classe ci-dessous. Dans ma AdvancedDataGrid j`utilise les parametres suivants:
Code:
1 2
| selectionMode="singleCell"
allowMultipleSelection="false" |
Tout fonctionne correctement sauf que la grille me permet de faire la sélection de plusieurs cellules et ne remet pas à jour la cellule déjà sélectionnée si j`en sélectionne une autre. Si je n`utilise pas la classe comme renderer tout fonctionne normalement, mais quand la classe est utilisée celà semble ralentir le traitement et me cause des problemes.
Pourrais-je ajuster certains paramètres pour régler ce problème qui me semble en être un de performance? En fait je me demande quel est le problème.
Code:
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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
| package vues
{
import mx.containers.VBox;
import mx.containers.HBox;
import mx.controls.TextArea;
import mx.controls.dataGridClasses.DataGridListData;
import mx.controls.listClasses.BaseListData;
import mx.controls.listClasses.IDropInListItemRenderer;
public class gridColonne2 extends HBox implements IDropInListItemRenderer
{
protected var _listData:DataGridListData;
override public function set data(value:Object):void
{
var pointeur:int = 0;
var texteTreat:String = null;
var texteLoop:String = null;
var codeTraite:String = null;
var codeTransport:String = null;
var colCNo:String = null;
var colINo:int = 0;
var texte:String = null;
var flagConfirme:Boolean = false;
var flagPeriod:Boolean = false;
var flagAnticipe:Boolean = false;
var texteBox1:TextArea = new TextArea();
var texteBox2:TextArea = new TextArea();
var texteBox3:TextArea = new TextArea();
var texteStr1:String = new String();
var texteStr2:String = new String();
var texteStr3:String = new String();
var boite:HBox = new HBox();
texteTreat = value[DataGridListData(_listData).dataField];
colCNo = DataGridListData(listData).dataField.substring(3);
colINo = parseInt(colCNo) - 1;
this.removeAllChildren();
if (texteTreat.length > 0){
while (texteTreat.indexOf(";") >= 0){
texteLoop = texteTreat.substring(0,texteTreat.indexOf(";"));
texteTreat = texteTreat.substring(texteTreat.indexOf(";")+1);
pointeur = parseInt(texteLoop.substring(0, texteLoop.indexOf(",")));
texteLoop = texteLoop.substring(texteLoop.indexOf(",")+1);
codeTraite = texteLoop.substring(0,1);
if (this.document.trspsap[pointeur].Ztypetrspflex == "0") {
codeTransport = "(C)";
flagConfirme = true;
}else if (this.document.trspsap[pointeur].Ztypetrspflex == "1") {
codeTransport = "(P)";
flagPeriod = true;
}else{
codeTransport = "(A)";
flagAnticipe = true;
}
if (codeTraite == "D" || codeTraite == "F") {
if (codeTraite == "D") {
if (this.document.trspsap[pointeur].Ztypetrspflex == "0"){
texte = codeTransport + this.document.trspsap[pointeur].Tknum + "-(" + this.document.trspsap[pointeur].Sttrg + ")-" + this.document.trspsap[pointeur].Kunnr;
texte = texte + "\n" + this.document.trspsap[pointeur].Lfimg + " Un " + this.document.trspsap[pointeur].Volum + " " + this.document.trspsap[pointeur].Voleh;
}else{
texte = codeTransport + this.document.trspsap[pointeur].Kunnr + "-" + this.document.trspsap[pointeur].Name1;
texte = texte + "\n" + this.document.trspsap[pointeur].Lfimg + " Un";
}
}else{
if (this.document.trspsap[pointeur].Ztypetrspflex == "0"){
texte = codeTransport + this.document.trspsap[pointeur].Tknum + "-(Fin Transport)";
}else{
texte = codeTransport + this.document.trspsap[pointeur].Kunnr + "-(Fin Transport)";
}
}
if (this.document.trspsap[pointeur].Ztypetrspflex == "0") {
if (texteStr1.length > 0) {
texteStr1 = texteStr1 + "\n";
}
texteStr1 = texteStr1 + texte;
}else if (this.document.trspsap[pointeur].Ztypetrspflex == "1") {
if (texteStr2.length > 0) {
texteStr2 = texteStr2 + "\n";
}
texteStr2 = texteStr2 + texte;
}else{
if (texteStr3.length > 0) {
texteStr3 = texteStr3 + "\n";
}
texteStr3 = texteStr3 + texte;
}
}
}
texteBox1.percentHeight = 100;
texteBox1.percentWidth = 100;
texteBox1.text = texteStr1;
texteBox1.setStyle("color", 0xFFFFFF);
if (colCNo != "0") {
texteBox1.setStyle("backgroundColor", this.document.legende.legendes[0].legendeColor);
}else{
texteBox1.setStyle("backgroundColor", this.document.legende.legendes[3].legendeColor);
}
texteBox2.percentHeight = 100;
texteBox2.percentWidth = 100;
texteBox2.text = texteStr2;
texteBox2.setStyle("color", 0xFFFFFF);
texteBox2.setStyle("backgroundColor", this.document.legende.legendes[1].legendeColor);
texteBox3.percentHeight = 100;
texteBox3.percentWidth = 100;
texteBox3.text = texteStr3;
texteBox3.setStyle("color", 0xFFFFFF);
texteBox3.setStyle("backgroundColor", this.document.legende.legendes[2].legendeColor);
if (flagConfirme == true) {
this.addChild(texteBox1);
}
if (flagPeriod == true) {
this.addChild(texteBox2);
}
if (flagAnticipe == true) {
this.addChild(texteBox3);
}
}else{
if (colINo >= 0 && (this.document.caleattr[colINo].Freeday == "X" || this.document.caleattr[colINo].Holiday == "X")) {
boite.percentHeight = 100;
boite.percentWidth = 100;
boite.setStyle("backgroundColor", 0x999999);
this.addChild(boite);
}
}
}
public function get listData():BaseListData
{
return _listData;
}
public function set listData(value:BaseListData):void
{
_listData = DataGridListData(value);
/* invalidateProperties(); */
}
}
} |
Merci de votre attention.