我试图复制单元格的文本内容 - 我不需要能够粘贴到Excel或其他任何内容,我只想要明文内容。突出显示文本,右键单击和选择复制按预期工作(因为我可以选择文本,因此与SlickGrid and Text Selection中的问题不同)但突出显示并按ctrl + c则不会(没有任何内容被复制到剪贴板)。 / p>
我尝试在slick.grid.js($canvas.on("keydown", handleKeyDown)
和$focusSink.add($focusSink2).on("keydown"), handleKeyDown)
)中注释掉按键处理代码,但没有变化。
Windows 10上的Chrome 61,如果重要的话。
使用Basic use with configuration示例重现,并将enableTextSelectionOnCells设置为true:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="shortcut icon" type="image/ico" href="favicon.ico" />
<title>SlickGrid example 1: Basic grid</title>
<link rel="stylesheet" href="../slick.grid.css" type="text/css"/>
<link rel="stylesheet" href="../css/smoothness/jquery-ui-1.11.3.custom.css" type="text/css"/>
<link rel="stylesheet" href="examples.css" type="text/css"/>
</head>
<body>
<div id="myGrid" style="width:600px;height:500px;"></div>
<script src="../lib/jquery-1.11.2.min.js"></script>
<script src="../lib/jquery.event.drag-2.3.0.js"></script>
<script src="../slick.core.js"></script>
<script src="../slick.grid.js"></script>
<script>
var grid;
var columns = [
{id: "title", name: "Title", field: "title"},
{id: "duration", name: "Duration", field: "duration"},
{id: "%", name: "% Complete", field: "percentComplete"},
{id: "start", name: "Start", field: "start"},
{id: "finish", name: "Finish", field: "finish"},
{id: "effort-driven", name: "Effort Driven", field: "effortDriven"}
];
var options = {
enableCellNavigation: true,
enableTextSelectionOnCells: true,
enableColumnReorder: false
};
$(function () {
var data = [];
for (var i = 0; i < 500; i++) {
data[i] = {
title: "Task " + i,
duration: "5 days",
percentComplete: Math.round(Math.random() * 100),
start: "01/01/2009",
finish: "01/05/2009",
effortDriven: (i % 5 == 0)
};
}
grid = new Slick.Grid("#myGrid", data, columns, options);
})
</script>
</body>
</html>
答案 0 :(得分:0)
我可以使用以下示例获取“复制到剪贴板”的功能: https://6pac.github.io/SlickGrid/examples/example-excel-compatible-spreadsheet.html
我不在乎粘贴或其他许多Excel功能,因此我将readOnlyMode
设置为:
grid.registerPlugin(new Slick.CellExternalCopyManager({
readOnlyMode : true,
includeHeaderWhenCopying : false,
}));