<html>
<head>
<title>ActiveWidgets Grid :: Examples</title>
<style> body, html {margin:0px; padding: 0px; overflow: hidden;} </style>
<!-- ActiveWidgets stylesheet and scripts -->
<link href="../../runtime/styles/xp/aw.css" rel="stylesheet" type="text/css" ></link>
<script src="../../runtime/lib/aw.js"></script>
<!-- grid format -->
<style>
.aw-grid-control {height: 100; width: 100%; margin: 0px; border: none; font: menu;}
.aw-row-selector {text-align: center}
.aw-column-0 {width: 80px;}
.aw-column-1 {width: 200px;}
.aw-column-2 {text-align: right;}
.aw-column-3 {text-align: right;}
.aw-column-4 {text-align: right;}
</style>
</head>
<body>
<script>
var obj = new AW.UI.Grid;
obj.getHeaderText = function (i) {return "Column " + i };
obj.getCellText = function (i,j) {return i + ',' + j};
obj.getHeaderText = function (i) {return i };
obj.setRowCount(50);
obj.setColumnCount(5);
obj.setSelectionMode("multi-row-marker");
document.write(obj);
</script>
</body>
</html>
obj.onSelectedRowsChanged = function(arrayOfRowIndices){
this.timeout(function(){
this.setCurrentRow(arrayOfRowIndices[arrayOfRowIndices.length - 1]);
},0);
}
obj.onSelectedRowsChanged = function(){return true;}
var AORI_length ;
obj.onSelectedRowsChanged = function(arrayOfRowIndices){
if(AORI_length > arrayOfRowIndices.length){
this.setCurrentRow(arrayOfRowIndices[arrayOfRowIndices.length - 1]);
}
AORI_length = arrayOfRowIndices.length;
return true;
}
var select_all_header = new AW.UI.Checkbox;
select_all_header.setControlText("");
select_all_header.onControlValueChanged = function(){
if(change_source_is_row) return false;
toggleCheckBoxes(select_all_header.getControlValue());
this.refreshClasses();
return true;
}
var obj = new AW.Grid.Extended;
obj.setId("myGrid");
obj.setCellText(myData);
obj.setHeaderCount(1);
obj.setHeaderText(myHeaders);
obj.setColumnCount(myHeaders.length);
obj.setRowCount(myData.length);
obj.setVirtualMode(false);
obj.setFixedLeft(0);
obj.setSelectionMode("multi-row-marker");
obj.onSelectedRowsChanged = function(array){ mySelectionFunction(array); return true; };
obj.setHeaderTemplate(select_all_header, 0,0)
document.write(obj);
// My selection functions:
function toggleCheckBoxes(checked)
{
var rows_array = new Array();
for(i=0;i < myData.length;i++)
rows_array[i] = i;
if(checked)
{
obj.setSelectedRows(rows_array);
}
else
{
obj.setSelectedRows([]);
}
}
function mySelectionFunction(selected_array)
{
change_source_is_row = true;
if(selected_array.length == myData.length)
{
select_all_header.setControlValue(true);
}
else
{
select_all_header.setControlValue(false);
}
change_source_is_row = false;
}
var change_source_is_header = false;
obj.onSelectedRowsChanged = function(array){ mySelectionFunction(array); if(!change_source_is_header) return true; };
function toggleCheckBoxes(checked)
{
var rows_array = new Array();
for(i=0;i < myData.length;i++)
rows_array[i] = i;
change_source_is_header = true;
if(checked)
{
obj.setSelectedRows(rows_array);
}
else
{
obj.setSelectedRows([]);
}
change_source_is_header = false;
}
var rows_array = new Array();
for(i=0;i < myData.length;i++){ rows_array[i] = i; }
var ManualSelect = true;
select_all_header.onControlValueChanged = function(value){
ManualSelect = false;
if(value ){ obj.setSelectedRows(rows_array); }
if(!value ){ obj.setSelectedRows([]); }
}
///////////////////////////////////////
obj.onSelectedRowsChanged = function(array){
if(ManualSelect ){
//asign onValueChanged event to do nothing
select_all_header.onControlValueChanged = function(){ };
// change value ( without firing onValueChanged event )
array.length == myData.length ? select_all_header.setControlValue(true) : select_all_header.setControlValue(false);
// restore original onValueChanged event ( same as above )
select_all_header.onControlValueChanged = function(value){
ManualSelect = false;
if(value ){ obj.setSelectedRows(rows_array); }
if(!value ){ obj.setSelectedRows([]); }
}
return true ; // prevents auto scroll-top
}
else{ } // toogle All - checkbox is clicked ( no 'return true')
ManualSelect = true;
}
This topic is archived.