function restoreInitialSort(){
var count = obj.getRowProperty("count");
var array = [];
for (i=0; i<count; i++){
array[i] = i;
}
obj.setRowProperty("values", array);
obj.setSortProperty("index", -1);
obj.refresh();
}
var corner = obj.getLayoutTemplate().getContent("corner");
corner.setEvent("onclick", restoreInitialSort);
// create ActiveWidgets Grid javascript object
var obj = new Active.Controls.Grid;
// set number of rows/columns
obj.setRowProperty("count", 20);
obj.setColumnProperty("count", 5);
// provide cells and headers text
obj.setDataProperty("text", function(i, j){return myData[i][j]});
obj.setColumnProperty("text", function(i){return myColumns[i]});
// replace row header text with first data column
obj.setRowProperty("text", function(i){return this.getDataProperty("text", i, 0)});
// set indices of other columns
obj.setColumnProperty("values", [1,2,3,4]);
// set headers width/height
obj.setRowHeaderWidth("100px");
obj.setColumnHeaderHeight("20px");
// define template for the first column header
obj.defineTemplate("corner", new Active.Templates.Header);
// assign this template as the content of top left corner
obj.getLayoutTemplate().setContent("corner", function(){return this.getCornerTemplate(0)});
// adjust header template
var corner = obj.getCornerTemplate();
// redirect item property requests to column property
corner.getItemProperty = function(name){return this.getColumnProperty(name, 0)};
// disable resizing
corner.getContent("div").setEvent("onmousedown", null);
corner.getContent("div").setStyle("cursor", "default");
// set width and height
corner.setStyle("width", "100px");
corner.setStyle("height", "20px");
// text alignment
corner.setStyle("text-align", "center");
// write grid html to the page
document.write(obj);
This topic is archived.