3.2.0

Total line simulation

Until the next release with the promised total line in it, here's a way to simulate it, sorta...

1. Manually total the columns you want and add a row to the bottom of the grid with the totals in it. If you're generating the grid data dynamically like I am, you'll want to increment the value in obj.setRowCount();

2. Change the color of the total line if you wish. Search on 'row color' for past forum messages that cover this.

3. So far so good, but if you now try sorting on a column, all hell breaks loose. So we have to tweak the sort function in grid.js so that it doesn't sort the last line. The code in bold is what I added. This works for me so far, but I imagine there is a more proper way of doing this...

obj.sort = function(index, direction){
.
.
...
var a = {};
var rows = this.getRowProperty("values");
var lastrow = rows.pop():
...
// sort loop here

rows.push(lastrow);

this.setRowProperty("values", rows);
this.setSortProperty("index", index);
this.setSortProperty("direction", direction);
};
David Cooke
February 17,
That's meant to a semicolon at the end of rows.pop()
David Cooke
February 17,
This worked perfect
Thanks for your post
Server
July 20,
This doesn't seem to work in Firefox.
April 12,
Fix for Firefox:

Place this anywhere prior to calling Array.pop()


if (!Array.pop)
{
Array.pop = function ()
{
if (this.length > 0)
{
delete this[this.length - 1];
this.length--;
}
}
}
April 12,

This topic is archived.

See also:


Back to support forum