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
|
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" horizontalAlign="center" initialize="sessionConn.send();" show="newLoad();">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.collections.IViewCursor;
import mx.rpc.events.ResultEvent;
import mx.utils.object_proxy;
// Define a property for returning the new value to the cell.
public var result:String="";
[Bindable]
private var dpValue:Array = new Array();
private var allValue:Array = new Array();
private var open:Boolean = false;
private var lastType:String;
public function onChange():void
{
var index:int = editor.selectedIndex;
result = dpValue[index].data;
}
private function select_pdt(event:ResultEvent):void
{
var i:Number = -1;
var n:Number = -1;
lastType = data.typeProduit;
var tab:ArrayCollection = sessionConn.lastResult.Produit as ArrayCollection;
var cursor:IViewCursor = tab.createCursor();
while(!cursor.afterLast)
{
var currentObj:Object = cursor.current;
allValue.push({code:currentObj["CodeProduit"], nom:currentObj["NomProduit"], type:currentObj["CodeTypeProduit"], niveau:currentObj["CodeNiveauProduit"], lblNiveau:currentObj["LibelleNiveauProduit"]});
if (currentObj["CodeTypeProduit"] == lastType)
{
i++;
dpValue.push({label:currentObj["CodeProduit"] + ':' +currentObj["NomProduit"] + '; ' + currentObj["CodeNiveauProduit"] + ':' + currentObj["LibelleNiveauProduit"], data:currentObj["CodeProduit"]});
if (data.produit01 == currentObj["CodeProduit"])
{
n = i;
}
}
cursor.moveNext();
}
editor.selectedIndex = n;
}
private function reload():void
{
if(data.typeProduit != lastType)
{
lastType = data.typeProduit;
dpValue.length = 0;
var i:Number = -1;
var n:Number = -1;
for each(var obj:* in allValue)
{
if (obj.type == lastType)
{
i++;
dpValue.push({label:obj.code + ':' + obj.nom + '; ' + obj.niveau + ':' + obj.lblNiveau, data:obj.code});
if(obj.code == data.produit01)
{
n = i;
}
}
}
editor.selectedIndex = n;
}
}
private function newLoad():void
{
lastType = data.typeProduit;
dpValue.length = 0;
var i:Number = -1;
var n:Number = -1;
for each(var obj:* in allValue)
{
if (obj.type == lastType)
{
i++;
dpValue.push({label:obj.code + ':' + obj.nom + '; ' + obj.niveau + ':' + obj.lblNiveau, data:obj.code});
if(obj.code == data.produit01)
{
n = i;
}
}
}
editor.selectedIndex = n;
}
]]>
</mx:Script>
<mx:HTTPService id="sessionConn" url="http://10.10.12.18/amfphp/xml/Produit.xml" useProxy="false" result="select_pdt(event)"/>
<mx:ComboBox id="editor" dataProvider="{dpValue}" width="90" change="onChange()" dropdownWidth="500" focusIn="reload()"/>
</mx:VBox> |
Partager