Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Flex 3 AdvancedDataGrid Sort

Posted on 2011-02-16
1
Medium Priority
?
374 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
1 Comment
 
LVL 20

Accepted Solution

by:
ChristoferDutz earned 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
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 set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

927 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