Copy the row data on clipboard on select of a row in Angular UI-Grid

£可爱£侵袭症+ 提交于 2020-01-04 08:15:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!