|
let grid: Grid = new Grid({
dataSource: data,
beforeCopy: function(args) {
var headerName = [];
for (let i = 0; i < grid.columns.length; i++) {
headerName.push(grid.columns[i].headerText);
}
(grid.clipboardModule as any).copyContent = "";
(grid.clipboardModule as any).getCopyData(headerName, false, "\t", true);
(grid.clipboardModule as any).copyContent += "\n";
for (let j = 0; j < grid.getRows().length; j++) {
(grid.clipboardModule as any).copyContent += "\n";
var cells = (grid as any).getRows()[j].querySelectorAll(".e-rowcell");
(grid.clipboardModule as any).getCopyData(cells, false, "\t", true);
}
args.data = (grid.clipboardModule as any).copyContent;
},
columns: [
{
field: "OrderID",
headerText: "Order ID",
width: 120,
textAlign: "Right"
},
{ field: "CustomerName", headerText: "Customer Name", width: 150 },
{
field: "OrderDate",
headerText: "Order Date",
width: 130,
format: "yMd",
textAlign: "Right"
},
{ field: "Freight", width: 120, format: "C2", textAlign: "Right" },
{
field: "ShippedDate",
headerText: "Shipped Date",
width: 140,
format: "yMd",
textAlign: "Right"
},
{ field: "ShipCountry", headerText: "Ship Country", width: 150 }
]
});
grid.appendTo("#Grid");
var copyBtn = new Button();
copyBtn.appendTo("#copy");
document.getElementById("copy").addEventListener("click", function() {
grid.copy();
}); |