<html>
<head>
<link href="../../runtime/styles/xp/grid.css" rel="stylesheet" type="text/css" ></link>
<script src="../../runtime/lib/grid.js"></script>
<script src="../../patches/paging1.js"></script>
<style>
.active-controls-grid {height: 100%; border: 1px solid #ccc; font: menu;}
</style>
<script>
var myColumns = [
"Date","MAILFROM","RCPTTO","REJECTED","COUNT","SIZE"
];
var myData = [
["2006-06-01", "agpkvgymznezqo@pochta.ru", "info@domain.com", "blacklisted", "1", "0"],
["2006-06-01", "prdvtatajyao@qni.com", "info@domain.com", "read-error", "1", "0,03"],
["2006-06-01", "wwdvcfi@bgta.com", "asm@domain.com", "spam", "1", "0,01"],
["2006-06-01", "artf6ofqn7@mail.ru", "asm@domain.com", "spam", "1", "0,01"],
["2006-06-01", "talt@geta.com", "asm@domain.com", "spam", "1", "0,01"],
["2006-06-01", "chopino@entermediate.com", "asm@domain.com", "spam", "1", "0,01"],
["2006-06-01", "watson@airpower-ent.com", "asm@domain.com", "spam", "1", "0,01"],
["2006-06-01", "gmitchell@ae.com", "asm@domain.com", "spam", "1", "0,01"],
["2006-06-01", "Carolynjimzros@brainydictionary.com", "asm@domain.com", "spam", "1", "0"],
["2006-06-01", "Judithabqhwxjw@takebackthemedia.com", "asm@domain.com", "spam", "1", "0"],
["2006-06-01", "club79191296.1149116404@club.mnogo.ru", "asm@domain.com", "spam", "1", "0"],
["2006-06-01", "iyjxkmeqehp@hotmail.com", "asm@domain.com", "spam", "1", "0"],
["2006-06-01", "iny@bspa.com", "info@domain.com", "spam", "1", "0,05"],
["2006-06-01", "ujfqgeurztx@hopa.com", "info@domain.com", "spam", "1", "0,05"],
["2006-06-01", "hpsnolvxosa@misa.com", "info@domain.com", "spam", "1", "0,05"],
["2006-06-01", "tyaayp@ipla.com", "info@domain.com", "spam", "1", "0,05"],
["2006-06-01", "lztvf@pksa.com", "info@domain.com", "spam", "1", "0,04"],
["2006-06-01", "nzgmaf@pmh.com", "info@domain.com", "spam", "1", "0,04"],
["2006-06-01", "epnexj@zzra.com", "info@domain.com", "spam", "1", "0,04"],
["2006-06-01", "alkama@mail.ru", "info@domain.com", "spam", "1", "0,04"],
["2006-06-01", "twkf@upi.com", "info@domain.com", "spam", "1", "0,04"],
["2006-06-01", "shhqftr@gci.com", "info@domain.com", "spam", "1", "0,04"],
["2006-06-01", "ghost@kis.ru", "info@domain.com", "spam", "1", "0,04"],
["2006-06-01", "rzfjitg@cbra.com", "info@domain.com", "spam", "1", "0,04"],
["2006-06-01", "hvhn@brh.com", "info@domain.com", "spam", "1", "0,03"],
["-", "-", "-", "-", "25", "0,64"]
];
var myFooter = [];
for (i=0;i<myColumns.length;i++) myFooter[i] = myData[myData.length-1][i];
</script>
</head>
<body>
<hr>
<div>
<button onclick='goToPage(-Infinity)'><<</button>
<button onclick='goToPage(-1)'><</button>
<span id='pageLabel'></span>
<button onclick='goToPage(1)'>></button>
<button onclick='goToPage(Infinity)'>>></button>
<button onclick="SortWithFooter(5,'descending')">Sort by size (D)</button>
<button onclick="SortWithFooter(5,'ascending')">Sort by size (A)</button>
</div>
<hr>
<script>
var obj = new Active.Controls.Grid;
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Without paging everything works fine (just comment the line below)
// obj.setModel("row", new Active.Rows.Page);
obj.setRowProperty("count", myData.length);
obj.setColumnProperty("count", myColumns.length);
obj.setDataProperty("text", function(i, j){return myData[i][j]});
obj.setColumnProperty("text", function(i){return myColumns[i]});
obj.getTemplate("top/item").setEvent("onmousedown", null);
document.write(obj);
</script>
<script>
function goToPage(delta){
var count = obj.getProperty("row/pageCount");
var number = obj.getProperty("row/pageNumber");
number += delta;
if (number < 0) {number = 0}
if (number > count-1) {number = count-1}
document.getElementById('pageLabel').innerHTML = "Page " + (number + 1) + " of " + count + " ";
obj.setProperty("row/pageNumber", number);
obj.refresh();
}
goToPage(0);
function SortWithFooter(idx, direction) {
var index = obj.getProperty("selection/index");
deleteRow(false);
obj.sort(idx,direction);
addRow(myFooter, false);
obj.setProperty("selection/index",index);
obj.refresh();
};
function addRow(row, refresh){
var index_values = obj.getRowProperty("values");
// add new row
myData.push(row);
// update grid row indices
index_values.push(myData.length - 1);
obj.setRowProperty("values", index_values);
obj.setRowProperty("count", myData.length);
if (refresh) {this.obj.refresh();}
};
function deleteRow(refresh){
// Get existing sort values, re-number then deleted element
var array = obj.getRowProperty("values");
index = array.length-1;
var splice_point=-2;
var new_selected_row=-1;
for (var i=0;i<array.length;i++){
if (array[i] == index) splice_point=i;
if (array[i] > index) array[i]--;
if (splice_point == i-1) new_selected_row=array[i];
}
// Check the values are ok just to be sure
if (splice_point >= 0) array.splice(splice_point,1);
if (new_selected_row == -1) new_selected_row=array[array.length-1];
myData.splice(index,1);
// re-initialize the data values
this.obj.setDataProperty("count", myData.length);
// Put back the sort values
this.obj.setRowProperty("values", array);
// obj.setProperty("selection/index",new_selected_row);
this.obj.setProperty("selection/index",new_selected_row);
// refresh the grid
if(refresh) {obj.refresh();}
};
</script>
</body>
</html>
This topic is archived.