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

1

2

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.

enter image description here

Nathalia answered 16/8, 2019 at 7:34 Comment(1)
Looks like UI-Grid doesn't support this functionality directly. Any other trick or workaround please ?Nathalia
G
0

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.

Garmaise answered 2/9, 2019 at 8:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.