cjkao / slickdart

dart - slickgrid port
MIT License
23 stars 4 forks source link

Column sorting of booleans doesn't work. #48

Closed tonosama-atlacatl closed 8 years ago

tonosama-atlacatl commented 8 years ago

Looking at the ColumnFilter.dart example. This doesn't work:

/// web/example/ColumnFilter.dart ~ line 106
if(value1 is bool){
    return value1==true? 1:-1;
}

Part of the problem is that booleans don't have a 'compareTo' function. This has been in discussions for quite a while now... https://groups.google.com/a/dartlang.org/forum/#!msg/misc/5BxhAJJOyow/VrmDv8DtQ1wJ

A "not-so-fancy" solution:

if(val1.runtimeType == bool){
          result = (val1 == val2 ? 0 : (val1.toString().compareTo(val2.toString()) > 0 ? 1 : -1)) * sign;
}else{
          result = (val1 == val2 ? 0 : (val1.compareTo(val2) > 0 ? 1 : -1)) * sign;
}
tonosama-atlacatl commented 8 years ago

I think I found a better solution:

if(val1.runtimeType == bool)return (val1 == val2 ? 0 : (val1 == true?1:-1))*sign;
cjkao commented 8 years ago

ok, add in 749d060d5b3d49e81ace9b762a9f52e019590f76

tonosama-atlacatl commented 8 years ago

Also, this breaks if the column type is DateTime and some rows are null.