grid_obj.setAction("columnSort",
function(src)
{
var i = src.getItemProperty("index");
var d = (this.getSortProperty("index") == i) && (this.getSortProperty("direction")=="ascending") ? "descending" : "ascending";
window.status = "Sorting...";
this.sort(src,i, d);
//this.refresh();
this.timeout(function(){window.status = ""});
});
grid_obj.sort = function(src,index, direction){
var column = src.getItemProperty("text");
var model = this.getModel("row");
if (model.sort) {
return model.sort(index, direction);
}
var a = {};
var rows = this.getRowProperty("values");
if (direction && direction != "ascending" ) {
direction = "descending";
}
else {
direction = "ascending";
}
/*if (this.getSortProperty("index") != index)
{
for (var i=0; i<rows.length; i++)
{
a[rows[i]] = this.getDataProperty("value", rows[i], index).toLowerCase();
}
rows.sort(function(x,y){return a[x] > a[y] ? 1 : (a[x] == a[y] ? 0 : -1)});
if (direction == "descending")
{
rows.reverse();
}
}
else if (this.getSortProperty("direction") != direction) {
rows.reverse();
}*/
window.grid_data.location.replace("grid_data.php?fields=*&table=ad&order="+column+" "+(direction=="ascending" ? "ASC" : "DESC"));
this.setRowProperty("values", rows);
this.setSortProperty("index", index);
this.setSortProperty("direction", direction);
};
This topic is archived.