Solved

Flex 3 AdvancedDataGrid Sort

Posted on 2011-02-16
1
371 Views
Last Modified: 2012-05-11
I have an advanced datagrid display product information with a main category, sub category and then a list of products within that category.

Problem that I have is that all the product within the category are in a random order and even tho they are in order from the cfc, when outputted in the datagrid they are random.

I'm thinking this needs a sortCompare function but i'm not sure how to implement this into my code.  Any help be appriciated.

Heres the code for my results function:

public function resultGetSubmissionsByCategory(event:ResultEvent):void {
				
	               //results returned by the ColdFusion CFC are a query
	               //which can be cast to a Flex ArrayCollection object
	               submissionsAryCol = event.result as ArrayCollection;
				   submissionsAryCol.filterFunction = filterArrayLike;
	               
	               //convert the ArrayCollection to a GroupingCollection
	               var submissionsNameGroup:Grouping = new Grouping();
	               
	               //what column in the query results should be used to group on
	               var nameGroupFld1:GroupingField = new GroupingField("parentCategory") ;
	               var nameGroupFld2:GroupingField = new GroupingField("categoryDescription") ;
	               //set the fields property of the Grouping 
	               //to an array of GroupingField objects
	               submissionsNameGroup.fields = [ nameGroupFld1, nameGroupFld2 ];
	               
	               submissionsGroupColl =  new GroupingCollection();
	               
	               //set the source property of the GroupingCollection
	               //to the flat data ArrayCollection
	               submissionsGroupColl.source = submissionsAryCol;
	               
	               //set the grouping property of the GroupingCollection
	               //to the Grouping object that contains the fields
	               //to group the data on
	               submissionsGroupColl.grouping = submissionsNameGroup;
	               
	               //call refresh so the view is updated
	               submissionsGroupColl.refresh();	   
			}

Open in new window



0
Comment
Question by:RenAndStimpy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 20

Accepted Solution

by:
ChristoferDutz earned 500 total points
ID: 34906009
Well propably your list of products is a plain ArrayCollection. If this is the case you could initialize every one of these lists with a sorting function. Another alternative would be to use a custom dataProvider (by extending GroupingCollection or something similar).
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to how to record live broadcast.

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question