日期:2014-05-16  浏览次数:20326 次

ExtJS Grid 可以选择文字方法

How to select text in the grid (with the mouse) so that it can be copied to the clipboard

?

1.相关帖子:http://extjs.com/forum/showthread.php?p=154426#post154426

?

2.下面是Condor 使用的方法:

  • 首先添加CSS:
Html代码 复制代码
  1. <style?type="text/css">??
  2. ????.x-selectable,?.x-selectable?*?{ ??
  3. ????????-moz-user-select:?text!important; ??
  4. ????????-khtml-user-select:?text!important; ??
  5. ????} ??
  6. </style>??
<style type="text/css">
	.x-selectable, .x-selectable * {
		-moz-user-select: text!important;
		-khtml-user-select: text!important;
	}
</style>
  • 然后在grid的配置中使用该css

?

Js代码 复制代码
  1. var?grid?=?new?Ext.grid.GridPanel({ ??
  2. ???viewConfig:?{ ??
  3. ??????templates:?{ ??
  4. ?????????cell:?new?Ext.Template( ??
  5. ????????????'<td?class="x-grid3-col?x-grid3-cell?x-grid3-td-{id}?<SPAN?style="COLOR:?#808000">x-selectable</SPAN> ??
  6. ?{css}"?style="{style}"?????????????????????????tabIndex="0"?{cellAttr}>', ??
  7. ???????????????'<div?class="x-grid3-cell-inner?x-grid3-col-{id}"?{attr}>{value}</div>', ??
  8. ????????????'</td>'??
  9. ?????????) ??
  10. ??????} ??
  11. ???}, ??
  12. ???... ??
  13. });??
var grid = new Ext.grid.GridPanel({
   viewConfig: {
      templates: {
         cell: new Ext.Template(
            '<td class="x-grid3-col x-grid3-cell x-grid3-td-{id} x-selectable
 {css}" style="{style}"                         tabIndex="0" {cellAttr}>',
               '<div class="x-grid3-cell-inner x-grid3-col-{id}" {attr}>{value}</div>',
            '</td>'
         )
      }
   },
   ...
});

?

3.如果你想把它设置为GRID的默认属性,可以使用以下代码:

Js代码 复制代码
  1. <