bonjour
comment adapter cet exemple de tri :
http://www.foxarc.com/blog/article/69.htm
pour mon code, sachant que datagrid de mon code se rempli de la base de données en plus enlever le bouton sort, ne laisser que le clique sur les header de la grid
voici mon code :
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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
<?xml version="1.0" encoding="utf-8"?>
<s:Module xmlns:fx="http://ns.adobe.com/mxml/2009"
		  xmlns:s="library://ns.adobe.com/flex/spark"
		  xmlns:mx="library://ns.adobe.com/flex/mx"
		  xmlns:adminservice="services.adminservice.*"
		  width="100%" height="100%">
	<s:layout>
		<s:BasicLayout/>
	</s:layout>
	<fx:Declarations>
		<s:CallResponder id="getUserActionByActionCodeWithInWithLimitResult"/>
		<adminservice:AdminService id="adminService"
								   fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
								   showBusyCursor="true"/>
		<!-- Placer ici les éléments non visuels (services et objets de valeur, par exemple). -->
	</fx:Declarations>
	<fx:Script>
		<![CDATA[
			import mx.collections.ArrayCollection;
			import mx.controls.Alert;
			import mx.events.FlexEvent;
 
			public function gridSend():void{
				var actionCode : Array;
				var elementcodeAction : String;
				if(codeAction.text == "Send to E-mail [10]") { elementcodeAction = "10"; }
				if(codeAction.text == "Send to account [11]") { elementcodeAction = "11"; }
				if(codeAction.text == "Send to mobile [12]") { elementcodeAction = "12"; }
				if(codeAction.text == "Payment Eshop [14]") { elementcodeAction = "14"; }
				if(codeAction.text == "Prepaid Card Activation [8]") { elementcodeAction = "8"; }
				if(codeAction.text == "Bank Payment Card [17]") { elementcodeAction = "17"; }
				if(codeAction.text == "Deposit history [9]") { elementcodeAction = "9"; }
				if(codeAction.text == "Send money to phone SIP [19]") { elementcodeAction = "19"; }
				if(codeAction.text != "All Actions") {  
					actionCode = [elementcodeAction]; 
				} else {
					actionCode = ["10", "11", "12", "13", "14", "8", "17", "9", "19"];
				}
 
 
				var varstatus:String;
				if(statuscode.text == "0" || statuscode.text=="1"){
					varstatus= statuscode.text;
				} else varstatus= null;
 
 
				var varactiondate:Array 
				if(begindate.text!="" && enddate.text!=""){
					varactiondate = [begindate.text, enddate.text]; 
				} else varactiondate = null;
 
				getUserActionByActionCodeWithInWithLimitResult.token = adminService.getUserActions(offset.text, limit.text, account.text, actionCode, varactiondate, varstatus);
			}
 
 
			protected function dataGrid_creationCompleteHandler(event:FlexEvent):void
			{
				//getUserActionByActionCodeWithInWithLimitResult.token = adminService.getUserActionByActionCodeWithInWithLimit(sendCode, 100);
				/*var sendCode : ArrayCollection = new ArrayCollection();
				sendCode.addItem("10");
				sendCode.addItem("11");
				sendCode.addItem("12");
				getUserActionByActionCodeWithInWithLimitResult.token = adminService.getUserActionByActionCodeWithIn(sendCode);*/
				gridSend();
			}
 
			protected function ButtonSearch0_clickHandler(event:MouseEvent):void
			{
				getUserActionByActionCodeWithInWithLimitResult.token = adminService.getUserActionByOneActionCode(codeAction.selectedItem.value);
			}
 
			protected function list_clickHandler(event:MouseEvent):void
			{
				offset.text = '0';
				gridSend();
			}
 
			protected function ClearAll_clickHandler(event:MouseEvent):void
			{
				account.text = null;
				begindate.text = "";
				enddate.text = "";
				codeAction.text = "All Actions";
				statuscode.text = "All";
				gridSend();
			}
 
			protected function button9_clickHandler(event:MouseEvent):void
			{
				var varoffset:Number;
				varoffset = (parseInt(offset.text) - parseInt(limit.text));
				if(varoffset < 0){
					varoffset = 0;
				}
				offset.text = varoffset.toString();
				gridSend();		
			}
 
			protected function button8_clickHandler(event:MouseEvent):void
			{
				offset.text = (parseInt(offset.text) + parseInt(limit.text)).toString();
				gridSend();
			}
			///////////////
 
			import mx.collections.ArrayCollection;
			import mx.controls.DataGrid;
			import mx.controls.dataGridClasses.*;
			import mx.collections.*;
 
			public var sortColumn:GridColumn;
			public var sortIndex:int = -1;
			public var lastSortIndex:int = -1;
			public var sortDirection:String;
 
 
			[Bindable]
			private var myCollection:Array ;
 
			public function sortByColumn(index:int):void
			{
				myCollection =  dataGrid.dataProvider.toArray();
				var c:GridColumn = dataGrid.columns[index]; 
				var desc:Boolean = c.sortDescending;
				if (c.sortable)
				{
					var s:Sort = myCollection.sort;
					var f:SortField;
					if (s)
					{
						s.compareFunction = null;
						var sf:Array = s.fields;
						if (sf)
						{
							for (var i:int = 0; i < sf.length; i++)
							{
 
								if (sf[i].name == c.dataField)
								{
									f = sf[i]
									desc = !f.descending;
									break;
								}
							}
						}
					}
					else
						s = new Sort;
 
					if (!f)
						f = new SortField(c.dataField);
 
					c.sortDescending = desc;
					var dir:String = (desc) ? "DESC" : "ASC";
					sortDirection = dir;
 
					lastSortIndex = sortIndex;
					sortIndex = index;
					sortColumn = c;
					f.name = c.dataField;
					if (c.sortCompareFunction != null)
					{
						f.compareFunction = c.sortCompareFunction;
					}
					else
					{
						f.compareFunction = null;
					}
					f.descending = desc;
					s.fields = [f];
				}
				myCollection.sort = s;
				myCollection.refresh();
			}
			///////////////
 
		]]>
	</fx:Script>
	<s:HGroup top="5" width="99%" height="97%" horizontalAlign="left" horizontalCenter="0">
 
		<s:Panel width="250" height="100%" chromeColor="#F49C4E" title="Filter for Actions  :">
			<mx:Button x="119" y="459" label="Sort" click="sortByColumn(1);"/>
			<s:Label x="20" y="15" text="User ID"/>
			<mx:HRule x="0" y="71" width="100%"/>
			<mx:HRule x="0" y="229" width="100%"/>
			<mx:HRule x="0" y="154" width="100%"/>
			<mx:HRule x="0" y="339" width="100%"/>
			<s:Button id="ClearAll" x="112" y="351" height="30" label="Clear filter"
					  chromeColor="#CCCCCC" click="ClearAll_clickHandler(event)" color="#000000"
					  cornerRadius="0" skinClass="spark.skins.spark.ButtonSkin"/>
			<s:Button id="list" x="16" y="353" height="30" label="List" chromeColor="#CCCCCC"
					  click="list_clickHandler(event)" color="#000000" cornerRadius="0"
					  skinClass="spark.skins.spark.ButtonSkin"/>
			<s:Label x="21" y="249" fontWeight="bold" text="Action Date"/>
			<mx:DateField id="begindate" x="19" y="297" formatString="YYYY-MM-DD" yearNavigationEnabled="true"/>
			<mx:DateField id="enddate" x="135" y="296" formatString="YYYY-MM-DD" yearNavigationEnabled="true"/>
			<s:Label x="21" y="277" text="Begin Date"/>
			<s:Label x="135" y="276" text="End Date"/>
			<s:TextInput id="account" x="20" y="35" width="95" restrict="0-9"/>
			<s:Label x="18" y="90" text="Action code"/>
			<s:Label x="18" y="172" text="Status code"/>
			<mx:ComboBox id="codeAction" x="18" y="112" editable="false" tabIndex="7">
				<mx:ArrayList>
					<fx:Array>All Actions</fx:Array>
					<fx:Array>Send to E-mail [10]</fx:Array>
					<fx:Array>Send to account [11]</fx:Array>
					<fx:Array>Send to mobile [12]</fx:Array>
					<fx:Array>Payment Eshop [14]</fx:Array>
					<fx:Array>Prepaid Card Activation [8]</fx:Array>
					<fx:Array>Bank Payment Card [17]</fx:Array>
					<fx:Array>Deposit history [9]</fx:Array>
					<fx:Array>Send money to phone SIP [19]</fx:Array>
				</mx:ArrayList>				
			</mx:ComboBox>
			<mx:ComboBox id="statuscode" x="18" y="194" editable="false" tabIndex="7">
				<mx:ArrayList>					
					<fx:Array>All</fx:Array>
					<fx:Array>0</fx:Array>
					<fx:Array>1</fx:Array>
				</mx:ArrayList>				
			</mx:ComboBox>
		</s:Panel>
		<mx:Panel id="table_panel" width="100%" height="100%" layout="absolute" title="Results">
			<s:VGroup x="0" y="0" width="100%" height="100%">
				<s:DataGrid id="dataGrid" width="100%" height="100%" borderVisible="false" alternatingRowColors="[0xFFFFFF, 0xEDFFE9]"
							creationComplete="dataGrid_creationCompleteHandler(event)" editable="false"
							enabled="true" fontFamily="Verdana" fontWeight="normal"
							requestedRowCount="4" selectedIndex="0" textDecoration="none">
					<s:columns>
						<s:ArrayList>
							<s:GridColumn width="70" dataField="id" headerText="ID"></s:GridColumn>
							<s:GridColumn width="100" dataField="user_id" headerText="User ID"></s:GridColumn>
							<s:GridColumn width="100" dataField="status_code" headerText="Status code"></s:GridColumn>
							<s:GridColumn width="135" dataField="action_date" headerText="Action date"></s:GridColumn>
							<s:GridColumn itemRenderer="com.icosnet.components.RenderAction" width="170" dataField="action_code" headerText="Action code"></s:GridColumn>
 
							<s:GridColumn width="80" dataField="amount" headerText="Amount"></s:GridColumn>
							<s:GridColumn dataField="voucher_id" headerText="Voucher ID"></s:GridColumn>
							<s:GridColumn dataField="transaction_id" headerText="Transaction ID"></s:GridColumn>
							<s:GridColumn dataField="phone_sip" headerText="Phone SIP"></s:GridColumn>
							<s:GridColumn width="80" dataField="phone_amount" headerText="Phone Amount"></s:GridColumn>
							<s:GridColumn dataField="send_to" headerText="Send to"></s:GridColumn>
							<s:GridColumn width="80" dataField="balance" headerText="Balance"></s:GridColumn>
							<s:GridColumn width="80" dataField="cib" headerText="CIB"></s:GridColumn>
							<s:GridColumn width="80" dataField="card_number" headerText="Card Number"></s:GridColumn>
							<s:GridColumn width="80" dataField="payment_id" headerText="Payment ID"></s:GridColumn>
 
							<s:GridColumn width="80" dataField="email" headerText="Email"></s:GridColumn>
							<s:GridColumn width="80" dataField="mobile" headerText="Mobile"></s:GridColumn>
						</s:ArrayList>
					</s:columns>
					<s:typicalItem>
						<fx:Object id="id1" action_code="action_code1" action_date="action_date1"
								   amountTimeDataField="" customerDataField="" dateTimeDataField=""
								   extras="extras1" idDataField="Données d'exemple"
								   marchentDataField="Données d'exemple"
								   paiementDataField="Données d'exemple" session_id="session_id1"
								   status_code="status_code1" user_id="user_id1"></fx:Object>
					</s:typicalItem>
					<s:AsyncListView list="{getUserActionByActionCodeWithInWithLimitResult.lastResult}"/>
					<!--<s:ArrayList>
					<fx:Object idDataField="01" accountDataField="0770156231" ipDataField="Alger" startTimeDataField="21"></fx:Object>					
					</s:ArrayList>-->
				</s:DataGrid>
 
				<s:HGroup x="27" y="624" width="100%" height="57" paddingLeft="10" paddingTop="10">
					<s:Label color="#000000" text="Offset : "/>
					<s:TextInput id="offset" width="65" color="#D83939" restrict="0-9" text="0"/>
					<s:Label color="#000000" text="Limit : "/>
					<s:TextInput id="limit" width="65" color="#D83939" restrict="0-9" text="100"/>
					<s:Spacer width="28" height="33"/>
					<s:Button id="button9" height="30" label="&lt;&lt; Previous" chromeColor="#CCCCCC"
							  click="button9_clickHandler(event)" color="#000000" cornerRadius="0"
							  skinClass="spark.skins.spark.ButtonSkin"/>
					<s:Button id="button8" height="30" label="Next &gt;&gt;" chromeColor="#CCCCCC"
							  click="button8_clickHandler(event)" color="#000000" cornerRadius="0"
							  skinClass="spark.skins.spark.ButtonSkin"/>
				</s:HGroup>
			</s:VGroup>
		</mx:Panel>
	</s:HGroup>
</s:Module>