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
| <!--Vue de l'unité-->
<mx:Panel label="Profil de l'unité" x="22" y="10" width="1200" height="823" layout="absolute" borderColor="#E2E2E2" borderStyle="outset">
<mx:Accordion width="936" height="754" top="24" left="10">
<mx:Canvas label="Saisie des besoins" width="1000" height="426">
<mx:Panelwidth="543">
<mx:title><![CDATA[ Formulation Des Besoins D'une Unité]]></mx:title>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
// ArrayCollection dynamique
[Bindable]
public var information:ArrayCollection = new ArrayCollection([
{ARTICLE:0 ,QUANTITé:0 }
]);
// Initialise le DataGrid ayant pour id : tab
private function initDataGrid():void{
tab.dataProvider = information;
}
private function addLine():void{
// Récupération des entrées du formulaire
var addArticle:String = article.text;
var addQtité:String = qtité.text;
// Création d'un nouvel élément
var newItem:Object = new Object();
newItem.ARTICLE= addArticle;
newItem.QUANTITé = addQtité;
// Ajoute un élément
information.addItem(newItem);
//Exemple pour supprimer un élément en fonction de son index (dans une boucle for par exemple)
//information.removeItemAt(i);
}
private function removeLine():void{
var remove:int =parseInt(lig.text);
information.removeItemAt(remove);
}
]]>
</mx:Script>
<mx:DataGrid id="tab" />
<mx:Form>
<mx:HBox width="250">
<mx:Label text="ARTICLE : " width="80" />
<mx:TextInput id="article" width="160" />
</mx:HBox>
<mx:HBox width="250">
<mx:Label text="QUANTITé : " width="80" />
<mx:TextInput id="qtité" width="160" />
</mx:HBox>
<mx:HBox width="250">
<mx:Label text="UF:" width="80" />
<mx:TextInput width="160" />
</mx:HBox>
<mx:Button label="Ajouter" click="addLine()"/>
<mx:HBox width="250">
<mx:Button label="Suprimer" click="removeLine()"/>
<mx:TextInput id="lig" width="160" />
</mx:HBox>
</mx:Form>
<!-- tableau contenant les données du ArrayCollection -->
<!-- Formulaire d'ajout -->
<mx:Button label="Envoyer"/>
</mx:Panel>
</mx:Canvas> |
Partager