Hi,
I have been trying to allow users to copy cell content from DhtmlxGrid and have added following in my code mygrid.enableBlockSelection(true);
mygrid.forceLabelSelection(true);
What happens is that I am getting the block selection highlighted but no prompt for Copy comes. I have tried the same in Firefox and Chrome. I have also set “signed.applets.codebase_principal_support” property as true in my Firefox preferences.
Randomly a few times prompt for copy came but even after clicking on Copy nothing happened, i.e. no content was copied.
Also I am able to copy the content through javascript by calling “grid.copyBlockToClipboard()”.
The sample that you provided gives the following Error on pressing Ctrl+C
ErrorType : Clipboard
Description : Access to Clipboard denied
However, I used the same piece of code in My Application, but Ctrl+C is working only one out of 3 times. First time key press will not be detected, second time only Ctrl is detected (When I press Ctrl then itself KeyPressed method is invoked, it does not wait for the C to be pressed along with it). The third time everything works fine.
This sequence repeats exactly for n number of times.
mygrid.enableBlockSelection(true);
mygrid.attachEvent("onKeyPress",onKeyPressed);
function onKeyPressed(code, ctrl, shift) {
if ((code == 67 && ctrl)||code.charCode == 99) {
if (!mygrid._selectionArea)
return alert("You need to select a block area in grid first");
mygrid.setCSVDelimiter("\t");
mygrid.copyBlockToClipboard();
}
if (code == 86 && ctrl) {
mygrid.pasteBlockFromClipboard();
}
return true;
}
Also I am using Firefox browser.
The problem is that earlier Ctrl+C was not working but after putting signed.applets.codebase_principal_support property as true in about:config, everything works just fine, but I can’t expect anyone to make the change in their browsers before using this.
Issue with accessing to clipboard cannot be fixed with JavaScript. Clipboard operation is blocked at some browser due to security reasons. As a workaround you can try to use dhtmlxSreadsheet dhtmlx.com/blog/?p=1052
By default text selection was disabled in grid. So enable it by using,
In IE, use
var yourDiv= document.getElementById(“mygrid_div”);
yourDiv.onselectstart= “return true;”;
And in other browser, add css to that div #mygrid_div
{
-webkit-user-select: text; /* Chrome all / Safari all /
-moz-user-select: text; / Firefox all /
-ms-user-select: text; / IE 10+ */
/* No support for these yet, use at own risk */
-o-user-select: text;
user-select: text;
}