3.2.0

Fix...

I have a trouble with sorting strings... That problem does'nt exist if you are using english cause english don't have accents. But on other languages (spanish for example) it's a problem...
The problem is when grid sort words with char with accents. It is accent-sensitive, and is like capitals... not have to be sensitive, "a" and "á" is exactly the same value when sort... (no the same text).
OK, i have on work and I have fixed it (only a little) and have changed some the Active.Formats.String class:

/*****************************************************************

    ActiveWidgets Grid 1.0.0 (Free Edition).
    Copyright (C) 2004 ActiveWidgets Ltd. All Rights Reserved. 
    More information at http://www.activewidgets.com/

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*****************************************************************/

Active.Formats.String = Active.System.Format.subclass();

Active.Formats.String.create = function(){

/****************************************************************

    String data format.

*****************************************************************/

    var obj = this.prototype;

/****************************************************************

    Transforms the wire data into the primitive value.

    @param	data	(String) Wire data.
    @return		Primitive value.

*****************************************************************/

    var woSC=new Array('a','e','i','o','u');
    var wSC=new Array('á','é','í','ó','ú');

    obj.dataToValue = function(data)
    {

        data=data.toLowerCase();
        for (i=0; i<wSC.length; i++)
        {
            data=data.replace(wSC[i],woSC[i]);
        }
        return data;
    }

/****************************************************************

    Transforms the wire data into the readable text.

    @param	data	(String) Wire data.
    @return		Readable text.

*****************************************************************/

    obj.dataToText = function(data){
        return data;
    };
};

Active.Formats.String.create();


It work well with the grid examples and some of my codes... but on other does'nt work and i don't know why...

Code example (not work):
<HTML>
<HEAD>
<LINK href="scripts/classic/activeui.css" type="text/css" rel="stylesheet">
<script src="scripts/grid.js"></script>
<script>
var myData = [
 ['Row 1','5/10/2004','','0','0','1'] 
,['Row 2','5/10/2004','4/1/2005','','0','4'] 
,['Row 3','5/10/2004','','','0','5'] 
,['Row 4','5/10/2004','','4/1/2005','0','6'] 
,['Row 5','5/11/2004','','','0','11'] 
,['Row 6','5/11/2004','4/1/2005','','0','13'] 
,['Row 7','5/11/2004','','','0','14'] 
,['Row 8','5/13/2004','','','0','18'] 
,['Row 9','5/13/2004','','','0','19'] 
,['Row 10','5/13/2004','','','0','20'] 
,['Row 11','5/13/2004','','','0','22'] 
,['Row 12','5/13/2004','','','0','23'] 
,['Row 13','5/13/2004','4/1/2005','','0','24'] 
,['Row 14','5/18/2004','','','0','25'] 
,['Row 15','5/18/2004','','4/1/2005','0','27'] 
,['Row 16','5/18/2004','','','0','32'] 
,['Row 17','5/18/2004','','','0','35'] 
,['Row 18','5/18/2004','','','0','36'] 
,['Row 19','5/19/2004','1/30/2006','4/1/2005','0','38'] 
,['Row 20','5/19/2004','7/1/2004','6/30/2004','2','41'] 
,['Row 21','5/20/2004','','','0','42'] 
,['Row 22','5/20/2004','','','90000000','44'] 
,['Row 23','5/24/2004','','','0','46'] 
,['Row 24','5/24/2004','','','0','47'] 
];
        
var myColumns=["Name","Created","End","Start","Hours","ID"];
 
var obj = new Active.Controls.Grid;

var string = new Active.Formats.String;
var date  = new Active.Formats.Date;
var number  = new Active.Formats.Number;

obj.setRowCount(myData.length);
obj.setColumnCount(myColumns.length);

number.setTextFormat("#");					
date.setErrorText("Undefined");
date.setErrorValue(21774600000000);

var formats=[string,date,date,date,number,number];

obj.setColumnText(function(i){return myColumns[i]});
obj.setDataText(function(i, j){return formats[j].dataToText(myData[i][j])});
obj.setDataValue(function(i, j){return formats[j].dataToValue(myData[i][j])});

</script>
</HEAD>
<body>
<script>
document.write(obj);
</script>
</body>
</HTML>


I am begining to get crazy... ;-)
Tell me something...
Darius
June 2,
You will get something like Row 1, Row 11, Row 12 ... ?

Just small comment about your replacement code - it will only replace single instance of a particular character. To replace all instances you have to use regular expressions instead of simple string replacement.
Alex (ActiveWidgets)
June 3,

This topic is archived.

See also:


Back to support forum