context menu problem - V2
I'm having problems that when the context menu is triggered and you have a row selected that is off your current view, your view resets to where your selected row is before it shows the context menu. I tried resetting the selected row but to no avail. Currently, if you load this code and either have no row selected or select a row and then scroll away from it, then you right click with no selected row on the screen, the view will reset to the top (if nothing selected) or to the previously selected row.
Any ideas?
Any ideas?
<html>
<head>
<script src="/ActiveWidgets/runtime/lib/aw.js"></script>
<link href="/ActiveWidgets/runtime/styles/aqua/aw.css" rel="stylesheet"></link>
</head>
<body>
<style>
#contextmenu {
background-color: #c0c0c0;
border: 2px solid;
border-color: #f0f0f0 #909090 #909090 #f0f0f0;
left: 0px;
padding: 3px 3px 3px 3px;
position: absolute;
top: 0px;
visibility: hidden;
z-index: 600;
}
</style>
<script>
var headers = [
"header 1",
"header 2",
"header 3",
"header 4",
"header 5",
"header 6",
"header 7",
"header 8",
"header 9",
"header 10",
"header 11",
"header 12",
"header 13",
"header 14",
];
var table = new AW.Grid.Extended;
table.setId('myGrid');
table.setStyle('height', 300);
table.setStyle('width', '90%');
table.setColumnCount(12);
table.setColumnIndices([0,13,1,3,5,6,4,2,7,8,9,10]);
table.setHeaderText(headers);
table.setCellText(function(i, j){return j + "-" + i});
table.setVirtualMode(true);
table.setSelectorText(function(i){return this.getRowPosition(i)+1});
table.setSelectorVisible(true);
table.setSelectorResizable(true);
table.setHeaderHeight(20);
table.setSelectorWidth(25);
table.setRowCount(200);
table.setCellEditable(false); // disable editing
table.setSelectionMode("multi-row");
table.getCellTemplate().setEvent("oncontextmenu", raiseMenuEvent);
function raiseMenuEvent(event){
this.raiseEvent("onCellContextMenu", event, this.\$0,this.\$1);
}
var contextmenu = new AW.HTML.DIV;
contextmenu.setId('contextmenu');
document.write(contextmenu);
table.onCellContextMenu = function(event, col, row){
contextmenu.element().innerHTML = "Right Click Menu";
table.setSelectedRows([row]);
contextmenu.setStyle('left', event.clientX + "px");
contextmenu.setStyle('top', event.clientY + "px");
contextmenu.setStyle("visibility", "visible");
}
document.onclick = function() { contextmenu.setStyle("visibility", "hidden"); };
document.write(table);
</script>
</body>
</html>
Mike
September 25,