Solved

Flex 3 AdvancedDataGrid Sort

Posted on 2011-02-16
1
360 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 500 total points
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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 …
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
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 load their YouTube profile onto Flash Media Live Encoder.

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now