DHTMLX Docs & Samples Explorer

Copy to clipboard

To select area in grid press left mouse button and move mouse to spread selection.
Press Ctrl+C to copy selected rows into the clipboard, Ctrl+V to replace selected rows by rows from clipboard.
You can paste selected rows to eXcell.


Source
<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxgrid.css">
<link rel="stylesheet" type="text/css" href="../../codebase/skins/dhtmlxgrid_dhx_skyblue.css">
<script  src="../../codebase/dhtmlxcommon.js"></script>
<script  src="../../codebase/dhtmlxgrid.js"></script>
<script  src="../../codebase/dhtmlxgridcell.js"></script>
<script  src="../../codebase/ext/dhtmlxgrid_selection.js"></script>
<script  src="../../codebase/ext/dhtmlxgrid_nxml.js"></script>
<style>
.dhtmlxGrid_selection {
    -moz-opacity: 0.5;
    filter: alpha(opacity = 50);
    background-color:#83abeb;
    opacity:0.5;
}
</style>
 
 
 
<table width="100%">
    <tr>
        <td width="500px" valign="top">
            <div id="gridbox" style="width: 500px; height:270px; background-color:white;overflow:hidden"></div>
        </td>
        <td width="300px">
            <textarea style="font-size:8pt; font-family:Arial; width:400px; height:250px;" id="ser_1"></textarea>
        </td>
    </tr>
    <tr>
        <td></td>
        <td>
            <div><a href="#" onClick="showClipboard()">show clipboard</a></div>
        </td>
    </tr>
</table>
<br>
<script>
mygrid = new dhtmlXGridObject('gridbox');
mygrid.setImagePath("../../codebase/imgs/");
mygrid.setHeader("Sales,Book Title,Author,Price,In Store,Shipping,Bestseller,Date of Publication");
mygrid.setInitWidths("50,150,120,80,80,80,80,200");
mygrid.setColAlign("right,left,left,right,center,left,center,center");
mygrid.setColTypes("dyn,ed,ed,price,ch,co,ra,ro");
mygrid.setColSorting("int,str,str,int,str,str,str,date");
mygrid.enableAlterCss("even", "uneven");
mygrid.attachEvent("onKeyPress", onKeyPressed);
mygrid.attachEvent("onBeforeSelect", function() {
    return false;
});
mygrid.init();
mygrid.setSkin("dhx_skyblue");
mygrid.loadXML("../common/grid.xml");
mygrid.enableBlockSelection();
function onKeyPressed(code, ctrl, shift) {
    if (code == 67 && ctrl) {
        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.setCSVDelimiter("\t");
        mygrid.pasteBlockFromClipboard();
    }
    return true;
}
function showClipboard() {
    if (window.clipboardData);
    document.getElementById("ser_1").value = window.clipboardData.getData("Text");
}
window.onerror = function() {
    alert("Clipboard operations not enabled in your browser.");
    window.open("http://www.febooti.com/support/website-help/website-javascript-copy-clipboard.html", "_blank");
}
</script>