动态指定DataGrid的排序函数

public static function sortFunc1(field:String):Function{
    return function(obj1:Object, obj2:Object):uint{
        return ObjectUtil.numericCompare(Number((obj1[field.split(".")[0]] as Object)[field.split(".")[1]]),Number((obj2[field.split(".")[0]] as Object)[field.split(".")[1]]));
    }
}
public static function sortFunc2(field:String):Function{
    return function(obj1:Object, obj2:Object):uint{
        return ObjectUtil.stringCompare(obj1[field],obj2[field]);
    }
}


<mx:DataGridColumn headerText="处理对象名称"
                   sortCompareFunction="{DataGridUtil.sortFunc2('cldxmc')}"
                   dataField="cldxmc"/>


参考地址:http://www.webappsolution.com/wordpress/2010/03/31/reusable-numeric-sort-method-for-flex-datagrid-columns/

你可能感兴趣的:(排序,datagrid,Flex)