Reputation: 43
I am trying to find a way to copy cell content to clipboard in Kendo Grid HTML.
Any suggestions?
Upvotes: 0
Views: 932
Reputation: 1785
Something like this:
Set grid event
dataBound: function onDataBound(e) {
var grid = $("#Grid").data("kendoGrid");
$(grid.tbody).on("click", "td", function (e) {
var row = $(this).closest("tr");
var colIdx = $("td", row).index(this);
copyToClipboard(row ,colIdx);
});
}
And function to get and copy value
copyToClipboard=function(grid ,row ,idx){
var colName = grid.options.columns[idx].field;
var value= grid.dataItem(row)[colName];
window.prompt("Copy to clipboard: Ctrl+C, Enter", value);
}
I dont test it. May be there is better way to retrive cell value by row and column
Upvotes: 1