</head>
<body>
<script>
var obj = new AW.UI.Grid;
obj.setCellData("cell");
obj.setHeaderText("header");
obj.setColumnCount(10);
obj.setRowCount(10);
obj.setCellEditable(true);
obj.setSelectorVisible(true);
obj.setSelectorWidth(25);
obj.setSelectorText(function(i){return this.getRowPosition(i)+1});
obj.setSelectionMode("multi-row");
Array.prototype.max = function(){
return Math.max.apply({},this)
}
Array.prototype.min = function(){
return Math.min.apply({},this)
}
obj.onSelectorMouseDown = function(event, index) {
if (event.shiftKey) {
var selmin=obj.getSelectedRows().min();
var rowmin = Math.min(selmin,index);
var rowmax = Math.max(selmin,index);
selrows=[];
for(i=rowmin; i<=rowmax; i++){
selrows.push(i);
}
obj.setSelectedRows(selrows);
}
};
/*
obj.onRowMouseDown = function(event, index) {
if (event.shiftKey) {
var selmin=obj.getSelectedRows().min();
var rowmin = Math.min(selmin,index);
var rowmax = Math.max(selmin,index);
selrows=[];
for(i=rowmin; i<=rowmax; i++){
selrows.push(i);
}
obj.setSelectedRows(selrows);
}
};
*/
document.write(obj);
</script>
<br>
<button value="getSelectedRows" onClick="alert(obj.getSelectedRows());">get Selected Rows</button>
</body>
</html>
</head>
<body>
<script>
var obj = new AW.UI.Grid;
obj.setCellData("cell");
obj.setHeaderText("header");
obj.setColumnCount(10);
obj.setRowCount(10);
obj.setCellEditable(true);
obj.setSelectorVisible(true);
obj.setSelectorWidth(25);
obj.setSelectorText(function(i){return this.getRowPosition(i)+1});
obj.setSelectionMode("multi-row");
Array.prototype.max = function()
{return Math.max.apply({},this);}
Array.prototype.min = function()
{return Math.min.apply({},this);}
//Remove duplicate values and sort asc
function RemoveDuplicateValues(array)
{
var i,j,resultArray=[];
for (i = array.min(); i<=array.max();++i)
{
for (j=0;j<=array.length;++j)
{
if (array[j]==i)
{
resultArray.push(i);
break;
}
}
}
return resultArray;
}
var lastIndex;
obj.onRowMouseDown = function(event, index)
{
if ((event.shiftKey && event.ctrlKey) || event.shiftKey)
{
var rowmin = Math.min(lastIndex,index);
var rowmax = Math.max(lastIndex,index);
var selrows=[];
for(i=rowmin; i<=rowmax; ++i)
{selrows.push(i);}
if (event.ctrlKey) //&&event.shiftKey
{obj.setSelectedRows(RemoveDuplicateValues(obj.getSelectedRows().concat(selrows)));}
else //event.shiftKey
{obj.setSelectedRows(selrows);}
}
lastIndex = index;
};
document.write(obj);
</script>
<br>
<button value="getSelectedRows" onClick="alert(obj.getSelectedRows());">get Selected Rows</button>
</body>
</html>
if (event.ctrlKey) //&&event.shiftKey
{obj.setSelectedRows(selrows);}
else //event.shiftKey
{obj.setSelectedRows(RemoveDuplicateValues(obj.getSelectedRows().concat(selrows)));}
This topic is archived.