[Dojo-interest] Re: FilteringTable sort problem

Jonathan Bond-Caron jbondc at gmail.com
Fri Nov 3 13:48:33 MST 2006


Note that if your getting:

"7" > "37" == true.

The problem is your probably returning json data as:

"column1" : "10"   instead   of   "column1" : 10

I don't think it would be a good design decision to force the type in
the widget for every bit of data... and have it any slower

jon


Fargette, Jean-Christophe wrote:
> Thanks Andi.
>
> It's fixing my issue.
>
>
> -----Original Message-----
> From: dojo-interest-bounces at dojotoolkit.org
> [mailto:dojo-interest-bounces at dojotoolkit.org]On Behalf Of Andi Hotz
> Sent: November 3, 2006 3:25 PM
> To: dojo-interest at dojotoolkit.org
> Subject: [Dojo-interest] Re: FilteringTable sort problem
>
>
> Fargette, Jean-Christophe <JFargette <at> blgcanada.com> writes:
>
>   
>> Hi,
>>
>> I'm sorting a column called Version.
>>
>> The number are from 1 to 17 (example). I'm expecting to see the order
>>     
> 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17
>   
>> Instead my sorting is 1,10,11,12,13,14,15,16,17,2,3,4,5,6,7,8,9
>>
>> I tried to change type and sorttype from string to number but it doesn't
>>     
> change anything. The sort is working
>   
>> well on my others columns with types date and string. It seems it's only with
>>     
> numbers.
>   
>> Thanks
>> JC
>>     
> I have the same problem. By looking at the code of FilteringTable I found the
> lines that specifiy the sorting order (rev 6404):
> 623		if(a > b) ret = 1;
> 624		if(a < b) ret = -1;
> With some debuging I found the following result: a=7 and b=37 => 7 > 37 == false
> but the outcome is 1 so the comparison is actual "7" > "37" == true.
> Why that is so I have no idea since JavaScript should recognice both a and b as
> numbers ...
> So one solution is you cast exprecitly by replacing the above code by
> 		if (Number(a)!=NaN && Number(b)!=NaN){
> 			if(Number(a) > Number(b)) ret = 1;
> 			if(Number(a) < Number(b)) ret = -1;
> 		} else {
> 			if(a > b) ret = 1;
> 			if(a < b) ret = -1;
> 		}
> But there have to be a better solution since you specify the data type of the
> column and this information should be somewhere in the metadata of the widget
>
> Cheers
>
> Andy
>
>
>
>
>
> _______________________________________________
> Dojo FAQ: http://dojo.jot.com/FAQ
> Dojo Book: http://manual.dojotoolkit.org/DojoDotBook
> Dojo-interest at dojotoolkit.org
> http://dojotoolkit.org/mailman/listinfo/dojo-interest
> _______________________________________________
> Dojo FAQ: http://dojo.jot.com/FAQ
> Dojo Book: http://manual.dojotoolkit.org/DojoDotBook
> Dojo-interest at dojotoolkit.org
> http://dojotoolkit.org/mailman/listinfo/dojo-interest
>
>   


More information about the Dojo-interest mailing list