arlull
arlull

Reputation:

Flex - how do I sort a datagrid column that is using an item renderer in the header?

I am using an advanced data grid that is using a custom item renderer for the column heading and now sorting doesn't work. If I take out the custom renderer it works fine but I need it to work with the renderer. Does anyone know how to do this? I am new to Flex and ActionScript.

Upvotes: 1

Views: 7340

Answers (1)

danjarvis
danjarvis

Reputation: 10190

You need to implement a sortCompareFunction for the DataGrid column:

For example:

<mx:DataGridColumn headerText="Foo" dataField="bar" sortCompareFunction="compareTypes">

Lets just pretend that this DataGridColumn as an inline item renderer...

And then the function is defined as follows:

public static function compareTypes(typeOne:Object, typeTwo:Object):int
{
    return ObjectUtil.stringCompare(String(typeOne.foo), String(typeTwo.foo));
}

Upvotes: 1

Related Questions