角度ui网格不能复制单元格文本 [英] Angular ui-grid can not copy cell text

查看:372
本文介绍了角度ui网格不能复制单元格文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ui网格,其中我想通过单击任何行上的任何位置选择行。
我也想要将单元格内容复制到剪贴板。
我使用了以下代码,但 enableFullRowSelection true ,我无法通过鼠标拖动来选择单元格内容。



请参阅



您可以向网格元素添加一个类,如下所示

 < div style =height:200px
class =ui-grid-selectable
data-ui-grid =gridOptions
data-ui-grid-selection>< / div>

.ui-grid-selectable .ui-grid-disable-selection {
-webkit-touch-callout:default;
-webkit-user-select:text;
-khtml-user-select:text;
-moz-user-select:text;
-ms-user-select:text;
user-select:text;
cursor:auto;
}

检查更新的 plunker


I have an ui-grid where I want to select row by clicking any where on any row. I also want to copy a cell content to clip board. I did the following code, but while enableFullRowSelection is true, I can not select cell content by mouse draging.

Please see the plunker. After further investigating I found .ui-grid-disable-selection class is being added to my grid.

So can any one suggest how to solve this?

EDIT: If I change enableFullRowSelection to false, I can select the content.

var app = angular.module('plunker', ['ui.grid', 'ui.grid.selection']);

app.controller('MainCtrl', function($scope) {
  $scope.name = 'World';
  $scope.data = [
    {a:'A', b:'B'},
    {a:'A1', b:'B1'},
    {a:'A2', b:'B2'},
    {a:'A3', b:'B3'},
    {a:'A4', b:'B4'}
    ];
  $scope.gridOptions = {
	data : 'data',
	enableRowSelection: true,
	enableFullRowSelection: true,
	enableHighlighting : true,
	multiSelect: false
  };
});

<!DOCTYPE html>
<html ng-app="plunker">

  <head>
    <meta charset="utf-8" />
    <title>AngularJS Plunker</title>
    <script>document.write('<base href="' + document.location + '" />');</script>
    <link rel="stylesheet" href="style.css" />
    <link rel="stylesheet" href="https://cdn.rawgit.com/angular-ui/bower-ui-grid/master/ui-grid.min.css" type="text/css" />
    <script data-require="angular.js@1.4.x" src="https://code.angularjs.org/1.4.7/angular.js" data-semver="1.4.7"></script>
    <script src="https://cdn.rawgit.com/angular-ui/bower-ui-grid/master/ui-grid.min.js"></script>
    <script src="app.js"></script>
  </head>

  <body ng-controller="MainCtrl">
    <p>Hello {{name}}!</p>
    
    <div style="height:200px" 
    data-ui-grid="gridOptions"
    data-ui-grid-selection></div>
    
  </body>

</html>

Please help.

解决方案

I think the easiest way is to just override the css class. If you check the ui-grid code then ui-grid-disable-selection class is added if both the flags are set

You can add a class to the grid element as shown below

    <div style="height:200px"
    class="ui-grid-selectable"
    data-ui-grid="gridOptions"
    data-ui-grid-selection></div>

    .ui-grid-selectable .ui-grid-disable-selection {
         -webkit-touch-callout: default;
         -webkit-user-select: text;
         -khtml-user-select: text;
         -moz-user-select: text;
         -ms-user-select: text;
         user-select: text;
         cursor:auto;
     }

Check the updated plunker.

这篇关于角度ui网格不能复制单元格文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆