Thanks for the code guys - I've got my grid working now using a
sortCompareFunction based on Iko's.
I just thought that this functionality would be built in as it seems to be
for the Flash datagrid. This appears to have a
DataGridColumn.sortOptionsproperty with values such as
Array.CASEINSENSITIVE and Array.NUMERIC
(see http://www.adobe.com/devnet/flash/quickstart/datagrid_pt2/ )
Cheers,
Paul.
On 05/05/07, iko_knyphausen <[EMAIL PROTECTED]> wrote:
You could also create a sortCompareFunction, similar to this one
private function sfSortFunction(ob1:Object, ob2:Object) : int
{
var s1 : String = ob1.dataField.toString().toLowerCase();
var s2 : String = ob2.dataField.toString().toLowerCase();
if (s1>s2)
return 1;
if (s1 < s2)
return -1;
return 0;
}
--- In [email protected] <flexcoders%40yahoogroups.com>, "Manish
Jethani" <[EMAIL PROTECTED]>
wrote:
>
> On 5/5/07, Paul Booth [EMAIL PROTECTED] wrote:
>
> > I can't find a way to tell the Datagrid (or DatagridColumn) to sort
in a
> > case-insensitive manner. Can someone please enlighten me?
>
> In your "headerRelease" event handler:
>
> import mx.collections.*;
>
> var col:ICollectionView = event.target.dataProvider;
> var s:Sort = col.sort ? col.sort : new Sort();
> var sf:SortField;
> if (col.sort && col.sort.fields) {
> for each (var f:SortField in col.sort.fields)
> if (f.name == event.dataField) {
> sf = f;
> break;
> }
> }
> if (!sf)
> sf = new SortField(event.dataField);
> sf.caseInsensitive = true;
> s.fields = [sf];
> col.sort = s;
>
> Disclaimer: Might be buggy.
>