Piyush Upadhyay
Piyush Upadhyay

Reputation: 445

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

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

Upvotes: 2

Views: 941

Answers (1)

Remko
Remko

Reputation: 359

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.

Upvotes: 0

Related Questions