:: Forum >> Version 2 >>

right click on a cell, select and copy data from cell

I need to be able to select data from any cell in a grid, copy it to the default to the default and paste it onto an outside application.
I am using version 2.1.
e.g. whether by clicking on a cell, or right clicking on it to reveal the edit menu. Right now when I right click on a cell, I get the edit menu, but the copy functionality is not available. Also selecting data on a cell, and doing a CTRL-C does not copy it to the clipboard.
Any hints on how to configure my grid so that I can do this??

Here is a view of my code

#myGrid {width: auto; overflow: auto; background: #e0daa7;}

.. columns
rows
.headers ..

#myGrid .aw-grid-row .aw-cells-selected {background: #FFFFFF;}



var myData = [..];


var myHeaders = [.];

var obj = new AW.Grid.Extended;

obj.setId("myGrid"); // necessary for CSS rules
obj.setVirtualMode(false); // disable virtual mode
obj.setCellText(myData); // 2-dimensional js array
obj.setCellEditable(true); enable editing
obj.setHeaderCount(1);
obj.setHeaderText(myHeaders); // js array (see top of this page)
obj.setColumnCount(8);
obj.setRowCount(<%=idataRecordSetSize%>);
obj.setSelectorVisible(true);
obj.setSelectorText(function(i){return this.getRowPosition(i)+1});
document.write(obj);
Paul W (Paul_Were
Thursday, August 24, 2006
Hi Paul W

You need to implement it youself.

This is how you can do it :

/* copy cell content to clipBoard */
obj.onKeyCtrlC = function(event){
var c = this.getCurrentColumn();
var r = this.getCurrentRow();
copyToClipBoard(removeCommas(this.getCellText(c, r)));
AW.setReturnValue(event, false); // prevent default
}
/* Copies text to system clipboard */
function copyToClipBoard(text) {
if (window.clipboardData) {
// the IE-manier
window.clipboardData.setData("Text", text);
}
return false;
}
/* Remove all commas from data */
function removeCommas(data) {
return replaceString(data,",",'');
}
/* Replaces all instances of a character with a new character in String */
function replaceString(sString, sReplaceThis, sWithThis) {
if (sReplaceThis != null && sReplaceThis != sWithThis) {
var counter = 0;
var start = 0;
var before = "";
var after = "";
while (counter<sString.length) {
start = sString.indexOf(sReplaceThis, counter);
if (start == -1){
break;
} else {
before = sString.substr(0, start);
after = sString.substr(start + sReplaceThis.length, sString.length);
sString = before + sWithThis + after;
counter = before.length + sWithThis.length;
}
}
}
return sString;
}
You can do ctrl+c using key board.The mousecontext menu you have to implement your self.contextmenu implementation is posted by me on this forum also.
Vikramaditya Garg
Friday, August 25, 2006



This topic is archived.

Back to support forum

Forum search