Flex PagedQuery does not perform sort with AdvancedDataGrid

46 views
Skip to first unread message

Y Borys

unread,
Feb 8, 2015, 3:59:34 PM2/8/15
to gran...@googlegroups.com
Sorting (by clicking column header) works well with mx:DataGrid and spark:DataGrid but with mx:AdvancedDataGrid - sortInfo sended to server is always null. 
Setting pagedQuery.multipleSort to true does not helps.
Changing sort descending/ascending within same column as well as setting sort programmatically works well.
Adding additional fields by clicking column header sort indicator area (multi column sort) when sort in not null works well.
But when clicked other column header (new sort) - sort become null.

Checked with
GDS 3.1.1-GA, Flash Builder 4.7, Flex SDK 4.6 and 4.13

Code
 [Bindable]
 
public var partyQuery:PagedQuery;
 
 
public var partyService:PartyService;


 
private function init():void {
     
Spring.getInstance().initApplication();
 
     
Spring.getInstance().mainServerSession.serverApp =
             
new SimpleServerApp("/server", false, "localhost", "8080");
 
     
Spring.getInstance().addComponent("partyService", PartyService);
 
     
Spring.getInstance().addComponentWithFactory("partyQuery", PagedQuery,
           
{ maxResults: 40, methodName: "findPersonByFilter", remoteComponentClass: PartyService, elementClass: Person });
 

     
var context:Context = Spring.getInstance().getSpringContext();
     partyQuery
= context.partyQuery;
 
     partyQuery
.multipleSort = true;
     partyQuery
.sort = new Sort();
     partyQuery
.sort.fields = [ new SortField("id") ];
     partyQuery
.refresh();
 
     partyService
= context.byType(PartyService) as PartyService;
 
     
Spring.getInstance().addComponent("dataTopic", DataObserver);
 
     context
.dataTopic.subscribe();
 
}
...........
 
<mx:AdvancedDataGrid id="productGrid" width="100%" height="100%" dataProvider="{partyQuery}" top="20" sortableColumns="true">
     
<mx:columns>
         
<mx:AdvancedDataGridColumn headerText="id" dataField="id" width="100"/>
         
<mx:AdvancedDataGridColumn headerText="First Name" dataField="currentFirstName" width="100"/>
         
<mx:AdvancedDataGridColumn headerText="Last Name" dataField="currentLastName" width="100"/>
         
<mx:AdvancedDataGridColumn headerText="DOB" dataField="birthDate"/>
     
</mx:columns>
 </
mx:AdvancedDataGrid>

Александр Шелюгов

unread,
Mar 24, 2015, 1:07:14 PM3/24/15
to gran...@googlegroups.com
Take a look here.
http://www.granitedataservices.com/public/docs/3.1.0/docs/reference/flex/graniteds-refguide-flex.html

>>Warning

Flex 4 Spark controls do not handle ItemPendingError by themselves and need a special wrapper AsyncListView.

So, in you code you should use something, like

private var/const dataProvider:IList;

init():void {
//...
dataProvider = new AsyncListView(partyQuery);
//...
}

/*
public function setDataProvider(list:IList):void {
dataProvider.list = list;
}
*/

<mx:AdvancedDataGrid id="productGrid" width="100%" height="100%" dataProvider="{dataProvider}" top="20" sortableColumns="true">

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/collections/AsyncListView.html

Y Borys

unread,
Mar 24, 2015, 1:56:20 PM3/24/15
to gran...@googlegroups.com
Thanks Alexander. This works. I was trying to use SortableAsyncListView in mxml without luck.

Александр Шелюгов

unread,
Mar 25, 2015, 4:02:29 AM3/25/15
to gran...@googlegroups.com
You may probably face some issue, if you save a list element from a different page somewhere else. I had error, like that, but I don't, or lazy to remember details. E.g.

<... id="something"... item="{productGrid.selectedItem}">

And scroll page with selected element away. I don't know how to properly handle this, except than making something.item equal to null.

вторник, 24 марта 2015 г., 20:56:20 UTC+3 пользователь Y Borys написал:

Александр Шелюгов

unread,
Mar 25, 2015, 4:34:09 AM3/25/15
to gran...@googlegroups.com
Actually, I'm probably wrong. Because, both AdvancedDataGrid and "custom googled" AutoComplete were using AsyncListView as their data provider.

среда, 25 марта 2015 г., 11:02:29 UTC+3 пользователь Александр Шелюгов написал:
Reply all
Reply to author
Forward
0 new messages