Hi,
that would be very nice!
I tried what Stefan wrote and it almost works ;)
I just added the ".toLowerCase()" to the four lines and there is just one more
problem:
If a f.e. german umlaut (ÜÄÖüäö) begins the string then the sorting is not
correct.
Maybe you could also add a ".replace" to temporarily replace f.e. Ü with UE ;)
then It should sort it correctly.
But that’s only for german umlaute. Maybe you can also replace other special
characters ;)
/*****************************************/
_defaultSortComparatorAscending :
function(row1, row2)
{
var obj1 = row1[arguments.callee.columnIndex].toLowerCase();
var obj2 = row2[arguments.callee.columnIndex].toLowerCase();
return (obj1 > obj2) ? 1 : ((obj1 == obj2) ? 0 : -1);
},
/**
* Default descendeing sort method to use if no custom method has been
* provided.
*
* @param row1 {var} first row
* @param row2 {var} second row
* @return {Integer} 1 of row1 is > row2, -1 if row1 is < row2, 0 if row1
== row2
*/
_defaultSortComparatorDescending :
function(row1, row2)
{
var obj1 = row1[arguments.callee.columnIndex].toLowerCase();
var obj2 = row2[arguments.callee.columnIndex].toLowerCase();
return (obj1 < obj2) ? 1 : ((obj1 == obj2) ? 0 : -1);
}
/*******************************************/
Would be very nice :D
Tobias
-----Ursprüngliche Nachricht-----
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Raul Gutierrez
S.
Gesendet: Donnerstag, 22. November 2007 15:15
An: qooxdoo Development
Betreff: Re: [qooxdoo-devel] table-sorting problem with lower and upper
casestrings
On Thu, 2007-11-22 at 15:01 +0100, Fa. Linstep, Stefan Volbers wrote:
> Hi Tobias,
>
> within qooxdoo0.6.6, I helped myself by overriding qx.Proto.sortByColumn
> in a custom sorting table model which is derived from
> qx.ui.table.SimpleTableModel, like that:
This is pretty interesting.. It would be nice to have this functionality
on 0.7 via something like tableModel.setCaseInsensitiveSorting(true).
I could make a patch, using this code, if it would have a chance of
being pushed in.
>
> ------------
> qx.Proto.sortByColumn = function(columnIndex, ascending) {
> // NOTE: We use different comperators for ascending and descending,
> // because comperators should be really fast.
> var comparator;
> if (ascending) {
> comparator = function(row1, row2) {
> var obj1 = (isNaN(row1[columnIndex]) ?
> row1[columnIndex].toLowerCase() : row1[columnIndex]); // overridden
> var obj2 = (isNaN(row2[columnIndex]) ?
> row2[columnIndex].toLowerCase() : row2[columnIndex]);
> return (obj1 > obj2) ? 1 : ((obj1 == obj2) ? 0 : -1);
> }
> } else {
> comparator = function(row1, row2) {
> var obj1 = (isNaN(row1[columnIndex]) ?
> row1[columnIndex].toLowerCase() : row1[columnIndex]);
> var obj2 = (isNaN(row2[columnIndex]) ?
> row2[columnIndex].toLowerCase() : row2[columnIndex]);
> return (obj1 < obj2) ? 1 : ((obj1 == obj2) ? 0 : -1);
> }
> }
>
> this._rowArr.sort(comparator);
>
> this._sortColumnIndex = columnIndex;
> this._sortAscending = ascending;
>
>
> this.createDispatchEvent(qx.ui.table.TableModel.EVENT_TYPE_META_DATA_CHANGED);
> }
>
> HTH
>
> Bye
> Stefan
>
>
> Tobias Koller (GERMO GmbH) schrieb:
> > hi hist,
> >
> >
> >
> > how can I sort the table if there are uppercase and lowercase strings in
> > on column?
> >
> >
> >
> > f.e: I have the following entries in column 1:
> >
> >
> >
> > A
> >
> > a
> >
> > B
> >
> > b
> >
> > C
> >
> > c
> >
> >
> >
> > if I sort them asc then it looks like:
> >
> >
> >
> > A
> >
> > B
> >
> > C
> >
> > a
> >
> > b
> >
> > c
> >
> >
> >
> >
> >
> > did I make something wrong?
> >
> >
> >
> > Thanks
> >
> > Tobias
> >
> >
> > ------------------------------------------------------------------------
> >
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by: Microsoft
> > Defy all challenges. Microsoft(R) Visual Studio 2005.
> > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > qooxdoo-devel mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2005.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
--
---------------------------
Raúl Gutierrez S.
Investigación y Desarrollo
Taller de Ideas S.A.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel