3.0 beta 2

How to sort inside a grid-subclass ? ....

I can't find any method for sorting inside a subclassed grid ( I tried everithing ) , an alert says it's already sorted but dont show it.
And after scrolling a while the cells texts are:
0.undefined 1.undefined ..... and so on
If anyone knows a .. how to, Please advise. Thanks
Here is the testing code:
<script> 
var SUBGrid = AW.UI.Grid.subclass();  
SUBGrid.create = function(){  
var obj = this.prototype;  
obj.PerformSort = function(index,direction){
obj.sort(index, direction);
}
}

var obj = new SUBGrid;
obj.setCellText(function(col, row){return col + "." + row}); 
obj.setHeaderText( function(col){return col });
obj.setVirtualMode(true); 
obj.setColumnCount(5); 
obj.setRowCount(10); 
document.write(obj);

var BUT1 = new AW.UI.Button;
BUT1.setControlText( 'Do sort' );
BUT1.onControlClicked = function(){ 
obj.PerformSort('1', "descending" );
alert(obj.getSortColumn() + '  ' + obj.getSortDirection(1) );
}
document.write(BUT1);
</script>

Carlos
August 20,
You should use this.sort() and not obj.sort() inside the new method - in this context obj variable refers to the prototype and not the actual instance of the new class (the second obj variable below).

var SUBGrid = AW.UI.Grid.subclass();
SUBGrid.create = function(){
    var obj = this.prototype;
    obj.PerformSort = function(index,direction){
        this.sort(index, direction);
    }
}

var obj = new SUBGrid;
...
Alex (ActiveWidgets)
August 21,

This topic is archived.

See also:


Back to support forum

Search

Version 2

Looking for AW 2.6 ?
The old site is here.