// Set Grid Headers, Cells and Formats
var obj = new AW.UI.Grid;
var myHeaders = ["Invoice Balance","Running Total"];
var myCells = [["10.00"],["20.00"],["30.00"],["40.00"]];
var num = new AW.Formats.Number;
num.setTextFormat('#,###.##');
obj.setCellFormat([num, num, num]);
// Running Total Function
function balance1(col, row)
{
var cell2 = obj.getCellValue(0, row);
var cell1 = obj.getCellValue(0, row-1);
var total = cell1 + cell2;
return total;
}
// Set Column Indices and Running Total Function into Column 1
obj.setColumnIndices([0, 1, 2]);
obj.setCellData(balance1,1);
// Set grid text
obj.setHeaderText(myHeaders);
obj.setCellText(myCells);
// set number of columns/rows
obj.setRowCount(myCells.length);
// write grid to the page
document.write(obj);
Invoice Balance, Running Total,
10.00 10.00
20.00 30.00
30.00 50.00
40.00 70.00
if (row == 0)
return obj.getCellValue(0, 0)
return obj.getCellValue(0, row) + obj.getCellValue(col, row - 1)
function runnintTotal(col, row) {
var count = 0;
var a=obj.getCellValue(0,row); // Column for an incrementing row ID
var b=obj.getRowCount();
var c = a-b;
for(var i=0;i<obj.getRowCount()+c;i++)
count += obj.getCellValue(1,i);
return count;
};
This topic is archived.