:: Forum >> Version 2 >>

Sorting on text but ignoring the some characters

ALex/All,

I have text column declared as string which has data like this

ORACLE
MSFT
--
--


The "--" is there in the grid where there are no stocks in the column.
When I sort on this column then sorting looks like

--
--
MSFT
ORACLE

How to ignore the string or character like "--" while doing sorting..
So the actual data rows would always come like below

MSFT
ORACLE
--
--

or

ORACLE
MSFT
--
--


This is urgent issue in AW2.5.4 we implemented in production...

Thanks & Regards


Ravindra Joshi
Tuesday, August 18, 2009
You'll need to write a custom sort routine. I did something similar last year. This should help you -
var     obj    = new AW.UI.Grid
var     SpecialSort     AW.Formats.String.subclass()
SpecialSort.create = function()
{
                var     
obj     this.prototype

                obj
.comparator = function(valuesgreaterlessequalerror)
                {
                    return function(
ij)
                    {
                        
try
                        
{
                            var 
values[i], values[j]

                            if (
a.indexOf("--") < && b.indexOf("--") < 0)
                            {
                                if (
b) {return greater}
                                if (
b) {return less}
                                return 
equal(ij)
                            }

                            if (
a.indexOf("--") == 0)
                            {
                                return 
greater == 1 ? greater less
                            
}
                            return 
greater == 1 ? less greater
                        
}
                        
catch(e){return error(ije)}
                    }
                }
}
obj.setCellFormat(new SpecialSort, <column position>)
 
Replace "<column position>" with the number of your target column.
Anthony
Tuesday, August 18, 2009



This topic is archived.

Back to support forum

Forum search