Auto Column resize to largest text size ..... AW 2.0 Version
I had a working Auto Column resize with AW 1.0 and was testing to see if everything with 2.0 would work the same as I already had in 1.0. But a lot of things do not work because of a little different syntax to 2.0 compared to 1.0.
Does anyone know the proper syntax to fix this is?
Here is what my original code was for Auto Sizing columns....
Does anyone know the proper syntax to fix this is?
Here is what my original code was for Auto Sizing columns....
/**** Autosize Columns ************/
var colSizes = new Array(myColumns.length) // array for colwidths
for (h=0;h<myColumns.length;h++){ // intialize with header widths
colSizes[h]= myColumns[h].length;
}
//get data function sets the col width for the
//data column if it is greater than the stored
//width
function getData(i, j){
chars = myData[i][j].length;
if ( chars > colSizes[j]) {
if (chars<70) { //70 char max to stop really wide cols.
colSizes[j] = chars;
} else {
colSizes[j] = 70;
}
}
return myData[i][j]
}
/*********************************/
//Need to go with AutoSizing of Columns
obj.setProperty("data/text", getData);
// write grid html to the page
document.write(obj);
// Autosizes Columns
var ssheet = document.getElementById("gridStyle").styleSheet;
for( cs=0;cs<myColumns.length-1;cs++) {
ssheet.addRule(".active-column-"+cs, "width:"+((colSizes[cs]*6)+20)+'px');
}
obj.getTemplate("layout").action("adjustSize");
obj.setDataProperty("value", function(i,j){
var text = "" + this.getDataText(i, j);
if (text.match(/^\s*$/)) {return ""}
var value = Number(text.replace(/[ ,%\$]/gi, "").replace(/\((.*)\)/, "-$1"));
return isNaN(value) ? text.toLowerCase() + " " : value;
});
var stylesheet = document.styleSheets[document.styleSheets.length-1];
stylesheet.addRule(".active-column-2", "width:150px");
Anthony
October 11,