flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kessler CTR Mark J" <mark.kessler....@usmc.mil>
Subject RE: AdvancedDatGrid sorting oddity
Date Fri, 20 Sep 2013 10:50:57 GMT
The first reference [1] never made much sense to me.  It sounds like it's allow the headerInfo.internalLabelFunction
to override the sorting ability which is just weird.  Especially since the sort.fields array
holds all the sortfields.  Label functions != sort compare functions.

[1] var headerInfo:AdvancedDataGridHeaderInfo = getHeaderInfo(column);         if(headerInfo
&& headerInfo.internalLabelFunction != null && column.sortCompareFunction
== null)             return;

The second reference [2]  is correct.  It is just copying the a custom compare function if
one is present on the column itself.  The custom compare functions override the default behavior
of that individual sortfield.

[2] if (column.sortCompareFunction != null)            field.compareFunction = column.sortCompareFunction;

More detail in general not necessary for the rest of the answer....

Well the other sortfields pretty much use custom compare functions over any internal ones.
 However the sortfields are not bound/referenced to the columns at all.  They add a New sortfield
(based off the columns sortfield / datafield) to the sort.fields array.  It's pretty much
a onetime event minus the fact the asc/desc gets updated.  

It sorts based on the sort array.  So it should be adding a sortfield if that column hasn't
added one already.   It should only test  if a function exists on column.sortCompareFunction
if it's going to pass it along to the sortfield when it's adding it (like the second reference
is correct).


-----Original Message-----
From: Justin Mclean [mailto:justin@classsoftware.com] 
Sent: Friday, September 20, 2013 12:17 AM
To: dev@flex.apache.org
Subject: AdvancedDatGrid sorting oddity


Near the top of addSortField we have:

if (headerInfo && headerInfo.internalLabelFunction != null && column.sortCompareFunction
== null)

Shouldn't that be column.sortCompareFunction != null? ie if you have a custom sort function
don't bother adding a new oridinary sort field?

Confusingly at the bottom of the same method:

if (column.sortCompareFunction != null)
	field.compareFunction = column.sortCompareFunction;

anyone have any insight?


View raw message