在Angular UI-Grid中选择一行时将行数据复制到剪贴板上 [英] Copy the row data on clipboard on select of a row in Angular UI-Grid
问题描述
我只需要选择/单击一行就可以将整个行数据复制到剪贴板上.我在共享共用网址时只能复制单元格文本-
http://plnkr.co/edit/EVrB5Ib9ZuqhbAMsV9Eg?p=preview
Pseduo网格选项代码如下-
*$scope.gridOptions = {
data : 'data',
enableRowSelection: true,
enableFullRowSelection: true,
enableHighlighting : true,
multiSelect: false,
enableRowHeaderSelection: false
};*
说,如果我单击第二行,则应同时复制"A1"和"B1",并且可以将它们粘贴在某些记事本或任何其他应用程序上.
我认为这需要几个步骤:首先,您必须注册rowSelectionChanged事件处理程序,以捕获选择中的任何更改.像这样:
$scope.gridOptions.onRegisterApi = function(gridApi) {
$scope.gridApi = gridApi;
gridApi.selection.on.rowSelectionChanged($scope,function(row){
if(row.isSelected) {
// copy row.entity data to clipboard
}
});
}
从AnularJS寻址剪贴板,我以前没有做过.看来此程序包可能是您想要的,但可能有所不同解决方案.
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.
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.
这篇关于在Angular UI-Grid中选择一行时将行数据复制到剪贴板上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!