Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4247884
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:10:19+00:00 2026-05-21T04:10:19+00:00

I have an AdvancedDataGrid with a HierarchicalCollectionView as its dataProvider. When I view the

  • 0

I have an AdvancedDataGrid with a HierarchicalCollectionView as its dataProvider. When I view the grid with the dataset I’m working with, and click the header of the column I wish to sort on, everything works perfectly. It sorts it hierarchically exactly how I would expect it to.

What I want to do now is have the grid already be sorted when it is shown to the user. Is there a way to do this programatically? I can’t for the life of me figure out how to do this, and clearly it’s possible since the AdvancedDataGrid has this built in.

Edit – BTW, I’ve tried this:

var myData:HierarchicalCollectionView = new HierarchicalCollectionView(theDataSource);

// Works fine using only the line above and clicking the header to sort.
// This is the part that I tried adding:
var sort:Sort = new Sort();

sort.fields = [new SortField("startDate")];

myData.sort = sort;
myData.refresh();

This appears to do something as far as sorting goes, but it doesn’t sort it in the same way as clicking the column header. “startDate” is a property of an object in theDataSource by the way.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T04:10:20+00:00Added an answer on May 21, 2026 at 4:10 am

    Looks like you want to sort dates. Sort can’t do that out of the box. You have to use a compareFunction.

    If your objects are of type Date it’s quite easy:

    var sortField:SortField = new SortField("startDate");
    sortField.compareFunction = ObjectUtil.dateCompare;
    

    In case your column contains dates as strings you’ll have to parse them first (code example from http://blog.flexexamples.com/2007/08/12/sorting-date-columns-in-a-datagrid/):

    private function date_sortCompareFunc(itemA:Object, itemB:Object):int
    {
        /* Date.parse() returns an int, but
           ObjectUtil.dateCompare() expects two
           Date objects, so convert String to
           int to Date. */
        var dateA:Date = new Date(Date.parse(itemA));
        var dateB:Date = new Date(Date.parse(itemB));
        return ObjectUtil.dateCompare(dateA, dateB);
    }
    
    var sortField:SortField = new SortField("startDate");
    sortField.compareFunction = date_sortCompareFunc;
    

    Then just use the sortField like you did in your example. That should work fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom column header renderer for my AdvancedDataGrid which has a
I have an AdvancedDataGrid that relies on a HierarchicalCollectionView as it's dataProvider. What I'd
I have an AdvancedDataGrid with mx:HierarchicalData as DataProvider. I need the grid to bi
I have an AdvancedDataGrid with a ArrayCollection as its dataProvider. For instance i have
Say I have this AdvancedDataGrid: <mx:AdvancedDataGrid id=grid height=384 width=100% styleName=aStyleName displayItemsExpanded=false groupItemRenderer=SomeRenderer draggableColumns=false defaultLeafIcon={null}
I have a AdvancedDatagrid with two columns lets say. First column has item renderer
I have an AdvancedDataGrid with XML dataProvider. Drag and drop in enabled, and works
I have an AdvancedDataGrid. One of the columns in the grid displayed with help
Is it possible to completely remove the sort arrows on an AdvancedDataGrid header? I
Is it possible to have a Button object in a column in an AdvancedDataGrid

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.