Thursday, February 10, 2011

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.

  • Check the info on this page.

    From le dorfier
  • I am also facing the same problem. Have you got any solution for this ?

  • 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));
    }
    
    From clownbaby

0 comments:

Post a Comment