3.2.0

It's a bug?

I have various columns in a grid and some of that are string formated with Active.Formats.String. But when i try to short don't do in a logical order, that is alphabetically. But other columns formated with Active.Formats.Number short perfectly... It's for this reason why I think that it's a bug...

Why happens that? How can I solve it?
JPM
May 5,
If it is not alphabetic order - its a bug. Can you post the example of the results?
Alex (ActiveWidgets)
May 5,
This is one little example... I think that I don't have any errors... There are some parts that i don't use, like date format...

<script>

var myData = [
['hhh','HHH','111','15'],
['qq','qqq','111','16'],
['333','dsa','22.22','20'],
['_UnDefined','asdfas','23','26'],
['Some','Description of Some','1000','30']
];
            
var obj = new Active.Controls.Grid;
var string = new Active.Formats.String;
var date  = new Active.Formats.Date;
var number  = new Active.Formats.Number;
var money  = new Active.Formats.Number;
                        
obj.setStyle("border", "1px solid");
obj.setRowCount(myData.length);
obj.setColumnCount(myColumns.length);
            
number.setTextFormat("#");
money.setTextFormat(".###,##");						
date.setDataFormat("auto");
date.setTextFormat("dd/mm/yyyy");
            
var formats = [string,string,money,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])});	
    
for (var col=0; col < (myColumns.length); col++) {
obj.getTemplate("column",col).setAttribute("title", function(){return this.getProperty("item/tooltip")});
obj.defineProperty("data/tooltip", function(i, col){if (myData[i][col]=="&nbsp;") { return ""; } else { return formats[col].dataToText(myData[i][col]);}});
}
obj.setAction("click", function(src){updata(formats[0].dataToText(myData[src.getRowProperty("index")][0]),formats[1].dataToText(myData[src.getRowProperty("index")][1]),formats[2].dataToValue(myData[src.getRowProperty("index")][2]),formats[3].dataToText(myData[src.getRowProperty("index")][3]))});
obj.setProperty("column/tooltip", function(i){return myColsTips[i]});
</script>
JPM
May 6,
If I sort on the first column - I get the following results:

333
Some
_UnDefined
hhh
qq

which looks correct for me. If you need case-insensitive sort - convert all strings to upper-case:
obj.setDataValue(
    function(i, j){
        return formats[j].dataToValue(myData[i][j]).toUpperCase();
    }
);
Alex (ActiveWidgets)
May 6,
That now works a little like i want... Now the order is correct... the proble was in the second column where the 'asdfas' value stay always at middle... look at that...

But works... thanks...
JPM
May 7,
Just one more thing, if i do that the number and date cols crash when i try to short...
JPM
May 7,
Sorry, you are right, toUpperCase should apply to strings only!
var string = new Active.Formats.String; 
string.dataToValue = function(data){
    return data.toUpperCase();
}

I should make it the default behavior anyway.
Alex (ActiveWidgets)
May 9,

This topic is archived.

See also:


Back to support forum