Bonjour
Je cherche une solution pour parvenir à selectionner plusieurs lignes dans un datagrid à l'aide de checkboxes.
merci
Bonjour
Je cherche une solution pour parvenir à selectionner plusieurs lignes dans un datagrid à l'aide de checkboxes.
merci
Bonjour
j'ai trouvée la solution,
voila un exemple qui illustre ce que j'ai voulez pour toute fin utile
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
56
57
58
59
60 <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" viewSourceURL="srcview/index.html"> <mx:Script> <![CDATA[ import mx.controls.CheckBox; import mx.collections.ArrayCollection; [Bindable] public var listeItemSelected : ArrayCollection = new ArrayCollection; public function cbAllHandler(evt : Event):void{ listeItemSelected.removeAll(); for each (var item:Object in dp){ item.selected = cbAll.selected; if(item.selected){ listeItemSelected.addItem(item); } } dp.refresh(); } public function onItemChanged(item : Object):void{ //Si l'item n'est pas déja dans la liste if(listeItemSelected.getItemIndex(item)==-1) { //on l'ajoute listeItemSelected.addItem(item); }else{ listeItemSelected.removeItemAt(listeItemSelected.getItemIndex(item)); //sinon on le supprime } } ]]> </mx:Script> <mx:ArrayCollection id="dp"> <mx:Array> <mx:Object songId="0" title="Astronaut" artist="David Byrne" selected="false"/> <mx:Object songId="1" title="Rio" artist="Duran Duran" selected="false"/> <mx:Object songId="2" title="Enjoy The Silence" artist="Depeche Mode" selected="false"/> <mx:Object songId="3" title="Mesopotamia" artist="B-52s" selected="false"/> </mx:Array> </mx:ArrayCollection> <mx:HBox> <mx:VBox width="100%" height="100%"> <mx:CheckBox id="cbAll" label="{(cbAll.selected)?'tout décocher':'tout cocher'}" change="cbAllHandler(event)"/> <mx:DataGrid dataProvider="{dp}" y="26" height="142"> <mx:columns> <mx:DataGridColumn width="25" paddingLeft="5" paddingRight="5"> <mx:itemRenderer> <mx:Component> <mx:CheckBox label="" selected="{data.selected}" click="{data.selected=!data.selected;outerDocument.onItemChanged(data)}"/> </mx:Component> </mx:itemRenderer> </mx:DataGridColumn> <mx:DataGridColumn headerText="Titre" dataField="title"/> <mx:DataGridColumn headerText="Artist" dataField="artist"/> </mx:columns> </mx:DataGrid> <mx:Label text="{dp.length+' résultat(s) '+listeItemSelected.length+' item(s) sélectionné(s)' }" /> </mx:VBox> <mx:List labelField="title" dataProvider="{listeItemSelected}" height="142"></mx:List> </mx:HBox> </mx:Application>
merci
Partager