:: 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(values, greater, less, equal, error)
{
return function(i, j)
{
try
{
var a = values[i], b = values[j]
if (a.indexOf("--") < 0 && b.indexOf("--") < 0)
{
if (a > b) {return greater}
if (a < b) {return less}
return equal(i, j)
}
if (a.indexOf("--") == 0)
{
return greater == 1 ? greater : less
}
return greater == 1 ? less : greater
}
catch(e){return error(i, j, e)}
}
}
}
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