actionscript 3 - Sort on datagrid also sort null values in flex -


today getting weird issue in datagrid.

<s:datagrid id="grid_result" dataprovider="{somelist}" sortablecolumns="true"> 

i have datagrid , on top header click sort column suppose column.

<s:gridcolumn headertext="temp" datafield="tempname"> 

it display tempname somelist. of data null. so, when sort column on header of column click sort null value also.

like display:

a b . . l m blank cell blank cell o p . . z 

it consider null value after m , before o. think consider null n(i may wrong this).

i want display null value @ last. have search lot not found solution.

any appreciated.

you can create custom sortcomparefunction , force using sortingcollator class, supposed handle null values.

private var collator:sortingcollator = new sortingcollator();  private function sortcomparefunction(obj1:object, obj2:object, gc:gridcolumn):int {     return collator.compare(obj1[gc.datafield], obj2[gc.datafield]); } 

and assign gridcolumn.

<s:gridcolumn headertext="temp" datafield="tempname" sortcomparefunction="sortcomparefunction"> 

Comments