复制extjs grid报表数据

复制extjs grid表格数据本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/dy_paradise/archive/2010

复制extjs grid表格数据

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/dy_paradise/archive/2010/01/19/5212389.aspx?

?

Ext.grid.GridPanel有一个重大缺陷,就是单元格的内容不能选中,没法选中就没法复制,给用户带来很多不便。

分析:?用IE Developer Toolbar打开ExtJs输出的代码研究了一下,发现每个单元格的div都有一个属性:unselectable="on",看来是css在作怪。

版本:?3.2.1

解决办法:?extJs官方论坛上有具体的解决办法,比较可行的如下。

step1:添加新的css样式。

<style type= "text/css" > .x-selectable, .x-selectable * { -moz-user-select: text! important ; -khtml-user-select: text! important ; } </style> ?

step2:修改Ext.grid.GridPanel的protoType,我是自己写了一个新的js文件,记得要在ext-all.js后面引入。

if (!Ext.grid.GridView.prototype.templates) { Ext.grid.GridView.prototype.templates = {}; } Ext.grid.GridView.prototype.templates.cell = new Ext.Template( '<td style="{style}" tabIndex="0" {cellAttr}>' , '<div {attr}>{value}</div>' , '</td>' ); ?

done!现在GridPanel的单元格可以选中了。

?