问题
I have the requirement of copying the whole row data on clipboard on just select/click of a row. I'm sharing the plunker URL where I'm only able to copy the cell text -
http://plnkr.co/edit/EVrB5Ib9ZuqhbAMsV9Eg?p=preview
Pseduo Code for Grid Options is as below-
*$scope.gridOptions = {
data : 'data',
enableRowSelection: true,
enableFullRowSelection: true,
enableHighlighting : true,
multiSelect: false,
enableRowHeaderSelection: false
};*
Say, If i click on second row, both 'A1' and 'B1' should get copied and the same can be pasted over some notepad or any other app.
回答1:
This requires several steps I think: first, you would have to register the rowSelectionChanged eventhandler, to capture any changes in selection. Something like:
$scope.gridOptions.onRegisterApi = function(gridApi) {
$scope.gridApi = gridApi;
gridApi.selection.on.rowSelectionChanged($scope,function(row){
if(row.isSelected) {
// copy row.entity data to clipboard
}
});
}
Addressing the clipboard from AnularJS I have not done before. It seems this package might be what you're looking for, but there may be different solutions.
来源:https://stackoverflow.com/questions/57520588/copy-the-row-data-on-clipboard-on-select-of-a-row-in-angular-ui-grid