FineUI 官方论坛

标题: 【分享】GridPanel中的数据内容不能复制解决办法 [打印本页]

作者: swtseaman    时间: 2012-5-17 16:29
标题: 【分享】GridPanel中的数据内容不能复制解决办法
首先庆贺自己被老大选为此区的版主!以后一定尽心做好一个版主应尽的义务!

废话不多说,进入正题!

不知道有多少朋友有这样的需求。我们用Grid显示出来的数据需要让用户可以选择后进行复制操作!(我在VIP区见到一个朋友提出这样的问题),现在把解决方法给大家分享一下!

1、首先在当前页面的<title>标签下加入如下css
<style type= "text/css" >   

    .x-selectable, .x-selectable * {   

        -moz-user-select: text! important ;   

        -khtml-user-select: text! important ;   

    }  

</style>

2、在文件尾加入如下js脚本,或者写一个新的js文件后在文件尾部调用
if  (!Ext.grid.GridView.prototype.templates) {   

    Ext.grid.GridView.prototype.templates = {};   

}   

Ext.grid.GridView.prototype.templates.cell =  new  Ext.Template(   

     '<td class="x-grid3-col x-grid3-cell x-grid3-td-{id} x-selectable {css}" class="{style}" tabIndex="0" {cellAttr}>' ,   

     '<div class="x-grid3-cell-inner x-grid3-col-{id}" {attr}>{value}</div>' ,   

     '</td>'

);

至此问题已完美解决,GridPanel里的所有内容(Header除外)都可随意选择、复制!
作者: support    时间: 2012-5-17 16:55
好办法,不过我想直接覆盖个css应该也行
作者: swtseaman    时间: 2012-5-17 17:33
这个就是比较灵活。比如有的页面我不想别人复制!
作者: support    时间: 2012-5-18 17:24
这个功能已经集成到ExtAspNet v3.1.6中了。多谢。

-为Grid增加属性EnableTextSelection,并增加示例grid/grid_textselection.aspx(swtseaman)。




欢迎光临 FineUI 官方论坛 (https://www.fineui.com/bbs/) Powered by Discuz! X3.4