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 6219921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:52:07+00:00 2026-05-24T07:52:07+00:00

I have an advanced data grid in flex (flash builder 4). It’s dataProvider is

  • 0

I have an advanced data grid in flex (flash builder 4). It’s dataProvider is pointing to an ArrayCollection (this._encounters).

Inside that array collection is a property that is an object (a client object).

I tried setting the dataField to “clientObj.firstName” to refer to the first name property within the clientObj property of the this._encounters array collection. It did not show anything.

So, I added a labelFunction to that column (code below) to set the text in the cell. This works fine and now I have values showing in the grid.

The problem is now when I click the title of column to sort it. It throws an error that property clientObj.firstName is not found in my array collection!

So, is there a better way to set the dataField / source for a column and point at a property in a sub-object — or a way to fix the sort?

Below the first column

<mx:AdvancedDataGrid x="0" y="25" id="adgEncounters" designViewDataType="flat" width="100%" height="100%" dataProvider="{this._encounters}">
<mx:columns>
<mx:AdvancedDataGridColumn headerText="first" dataField="clientObj.firstName" labelFunction="encounterGridLabelFunct"/>
<mx:AdvancedDataGridColumn headerText="first" dataField="thisWorksField"/>
</mx:columns>
</mx:AdvancedDataGrid>



protected function encounterGridLabelFunct(item:Object, column:AdvancedDataGridColumn):String //put just the HH:MM in to the grid, not the whole date string
{
 if(column.headerText=="first") result=item.clientObj.firstName;    
 return result;
}           

update:
Here is the final working code I used. 3 example sort functions, 1 for numeric sorting, 1 for String sorting and one for Date sorting (string date from a database).:

// sort adg column numerically
            private function numericSortByField(subObjectName:String, fieldName:String):Function
            {
                return function(obj1:Object, obj2:Object):int
                {
                    var value1:Number = (obj1[subObjectName][fieldName] == '' || obj1[subObjectName][fieldName] == null) ? null : new Number(obj1[subObjectName][fieldName]);

                    var value2:Number = (obj2[subObjectName][fieldName] == '' || obj2[subObjectName][fieldName] == null) ? null : new Number(obj2[subObjectName][fieldName]);
                    return ObjectUtil.numericCompare(value1, value2);
                }
            }

            //sort adg column string
            private function stringSortByField(subObjectName:String, fieldName:String):Function
            {
                return function(obj1:Object, obj2:Object):int
                {
                    var value1:String = (obj1[subObjectName][fieldName] == '' || obj1[subObjectName][fieldName] == null) ? null : new String(obj1[subObjectName][fieldName]);

                    var value2:String = (obj2[subObjectName][fieldName] == '' || obj2[subObjectName][fieldName] == null) ? null : new String(obj2[subObjectName][fieldName]);
                    return ObjectUtil.stringCompare(value1, value2);
                }
            }

            //sort adg date diff (takes date strings for example from a db)
            private function dateSortByField(subObjectName:String, fieldName:String):Function
            {
                return function(obj1:Object, obj2:Object):int
                {
                    var value1:String = (obj1[subObjectName][fieldName] == '' || obj1[subObjectName][fieldName] == null) ? null : new String(obj1[subObjectName][fieldName]);

                    var value2:String = (obj2[subObjectName][fieldName] == '' || obj2[subObjectName][fieldName] == null) ? null : new String(obj2[subObjectName][fieldName]);

                    var value1Date:Date = new Date();
                    var value1Time:int = value1Date.setTime(Date.parse(value1));

                    var value2Date:Date = new Date();
                    var value2Time:int = value2Date.setTime(Date.parse(value2));


                    return ObjectUtil.numericCompare(value1Time, value2Time);
                }
            }

In the mxml above, this is the changed line – notice the stringSortByField added:

        <mx:AdvancedDataGridColumn headerText="first" dataField="clientObj.firstName" sortCompareFunction="{stringSortByField('clientObj','firstName')}" labelFunction="encounterGridLabelFunct"/>

If it were a numeric field use the numericSortByField. If it were a date string from a database, use the dateSortByField function instead.

  • 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-24T07:52:08+00:00Added an answer on May 24, 2026 at 7:52 am

    You could use a custom compare function, thats how I do it (obviously your itemA
    and itemB will be different objects, so cast them as such):

    In your AdvancedDataGridColumn put in:

    sortCompareFunction="string_sortCompareFunc"
    

    and make the function:

    private function string_sortCompareFunc(itemA:Object, itemB:Object):int 
            {
                 var a:String = itemA as String;
                 var b:String = itemB as String;              
    
                 return ObjectUtil.stringCompare(a, b);
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

BackGround: I have an advanced data grid. The data provider for this ADG is
I have a data grid where I am displaying my messages. In that if
I have to populate an Advanced Data Grid which have the following fields: Continent->State->Society-->Actual
I have some rich text created using the flex (flash builder 4) rich text
I have used Infragistics UltraWinGrid to display data on the Grid. In this grid,
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 2 advanced data grids, one above the other. They both have the
I currently have an advanced search page that searches a number of fields in
I have a reasonably advanced (many patches and subpatches) quartz composition that was created
I have flex advancedDataGrid (could use dataGrid if that works better, though i like

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.